title: Loading JavaScript at runtime using Ajax
body: <p>In the post <a href="https://stackoverflow.com/questions/9037082/how-to-load-javascript-code-to-an-html-file-at-runtime">How to load javascript code to an html fil</a> there is a way to simple load an external js at runtime, and execute. But there is two issues: we don't know when it will be executed and we can't customize the code.</p>
  
  <p>I was using this code:</p>
  
  <pre><code>var elemScript=document.createElement('script');
  elemScript.setAttribute('type', 'text/javascript');
  elemScript.setAttribute('language', 'javascript');
  var txt = document.createTextNode(result);
  elemScript.appendChild(txt);
  document.head.appendChild(elemScript);
  </code></pre>
  
  <p>inside of an http request where result is the code provided by a php that make a customized code for me. Above I can dispatch some function that needs the code etc..</p>
  
  <p>But this beauty doesn't work in IE8 or older. Is there a way of make it work or maybe it's time to forget about these old navigators?</p>
  
  <p>Any suggestions? </p>