Dynamic javascript loading and execution
<p>I'm trying to dynamically load a Javascript based on the return value of an API call. I dynamically insert the script tag but it does not get executed. Can someone help understand why? The relevant code snippet is pasted below</p>

<pre><code>onError: function(code) {
      if(code == "false") {
        var headID = document.getElementsByTagName("head")[0];
        var scriptTag = document.createElement("script");
        scriptTag.type="text/javascript";
        scriptTag.src= 'scriptURL';
        headID.appendChild(scriptTag);
      }
}
</code></pre>

<p>Using firebug/chrome inspector, I can see that the script tag is added to the dom but the script is not executed (at least not that I can determine). It is a 3rd Party script hence I do not have direct control over it and hence cannot modify it either.</p>
