title: JavaScript onload/onreadystatechange not firing when dynamically adding a script tag to the page
body: <p>I am developing a bookmarklet that requires a specific version of jQuery be loaded on the page. When I have to dynamically insert a jQuery script tag to meet the requirments of the bookmarklet I want to wait for the onload or onreadystatechange event on the script tag before executing any function that requires jQuery.</p>
  
  <p>For some reason the onload and/or onreadystatechange events do not fire.  Any ideas on what I am doing wrong here?</p>
  
  <pre><code>var tag = document.createElement("script");
  tag.type = "text/javascript";
  tag.src = "http://ajax.microsoft.com/ajax/jquery/jquery-" + version + ".min.js";
  tag.onload = tag.onreadystatechange = function () {
      __log("info", "test");
      __log("info", this.readyState);
  };
  document.getElementsByTagName('head')[0].appendChild(tag);
  </code></pre>
  
  <p><strong>The FULL code:</strong> <a href="http://gist.github.com/405215" rel="nofollow noreferrer">http://gist.github.com/405215</a></p>