title: Injecting jQuery into a page fails when using Google AJAX Libraries API
body: <p>I'd like to inject jQuery into a page using the Google AJAX Libraries API, I've come up with the following solution:</p>
  
  <p><strong><a href="http://my-domain.com/inject-jquery.js" rel="nofollow noreferrer">http://my-domain.com/inject-jquery.js</a>:</strong></p>
  
  <pre><code>;((function(){
  
    // Call this function once jQuery is available
    var func = function() {
      jQuery("body").prepend('&lt;div&gt;jQuery Rocks!&lt;/div&gt;');
    };
  
    // Detect if page is already using jQuery
    if (!window.jQuery) {
      var done = false;
      var head = document.getElementsByTagName('head')[0];
      var script = document.createElement("script");
      script.src = "http://www.google.com/jsapi";
      script.onload = script.onreadystatechange = function(){
  
        // Once Google AJAX Libraries API is loaded ...
        if (!done &amp;&amp; (!this.readyState || this.readyState == "loaded" || this.readyState == "complete")) {
  
          done = true;
  
          // ... load jQuery ...
          window.google.load("jquery", "1", {callback:function(){
  
            jQuery.noConflict();
  
            // ... jQuery available, fire function.
            func();
          }});
  
          // Prevent IE memory leaking
          script.onload = script.onreadystatechange = null;
          head.removeChild(script);
        }
      }
  
      // Load Google AJAX Libraries API
      head.appendChild(script);
  
    // Page already using jQuery, fire function
    } else {
      func();
    }
  })());
  </code></pre>
  
  <p>The script would then be included in a page on a separate domain:</p>
  
  <p><strong><a href="http://some-other-domain.com/page.html" rel="nofollow noreferrer">http://some-other-domain.com/page.html</a>:</strong></p>
  
  <pre><code>&lt;html&gt;
    &lt;head&gt;
      &lt;title&gt;This is my page&lt;/title&gt;
    &lt;/head&gt;
    &lt;body&gt;
      &lt;h1&gt;This is my page.&lt;/h1&gt;
      &lt;script src="http://my-domain.com/inject-jquery.js"&gt;&lt;/script&gt;
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>In Firefox 3 I get the following error:</p>
  
  <pre><code>Module: 'jquery' must be loaded before DOM onLoad! jsapi (line 16)
  </code></pre>
  
  <p>The error appears to be specific to the Google AJAX Libraries API, as I've seen others use a jQuery bookmarklet to inject jQuery into the current page. My question:</p>
  
  <ul>
  <li>Is there a method for injecting the Google AJAX Libraries API / jQuery into a page regardless of the onload/onready state?</li>
  </ul>