How do you dynamically load a javascript file from different domain?
<p>I find this excellent code, posted by <a href="http://stackoverflow.com/users/28150/aemkei">aemkei</a> as answers to this questions:</p>

<ol>
<li><a href="http://stackoverflow.com/questions/21294/how-do-you-dynamically-load-a-javascript-file-think-cs-include">How do you dynamically load a javascript file? (Think C’s #include)</a></li>
<li><a href="http://stackoverflow.com/questions/203113/use-javascript-to-inject-script-references-as-needed">Use javascript to inject script references as needed?</a></li>
</ol>

<blockquote>
  <p>You may write dynamic script tags
  (using Prototype):</p>

<pre><code>new Element("script", {src: "myBigCodeLibrary.js", type: "text/javascript"});
</code></pre>
  
  <p>The problem here is that we do not
  know when the external script file is
  fully loaded.</p>
  
  <p>We often want our dependant code on
  the very next line and like to write
  something like:</p>

<pre><code>if (iNeedSomeMore){
  Script.load("myBigCodeLibrary.js");  // includes code for myFancyMethod();
  myFancyMethod();                     // cool, no need for callbacks!
}
</code></pre>
  
  <p>There is a smart way to inject script
  dependencies without the need of
  callbacks. You simply have to pull the
  script via a synchronous AJAX request
  and eval the script on global level.</p>
  
  <p>If you use Prototype the Script.load
  method looks like this:</p>

<pre><code>var Script = {
  _loadedScripts: [],
  include: function(script){
    // include script only once
    if (this._loadedScripts.include(script)){
      return false;
    }
    // request file synchronous
    var code = new Ajax.Request(script, {
      asynchronous: false, method: "GET",
      evalJS: false, evalJSON: false
    }).transport.responseText;
    // eval code on global level
    if (Prototype.Browser.IE) {
      window.execScript(code);
    } else if (Prototype.Browser.WebKit){
      $$("head").first().insert(Object.extend(
        new Element("script", {type: "text/javascript"}), {text: code}
      ));
    } else {
      window.eval(code);
    }
    // remember included script
    this._loadedScripts.push(script);
  }
};
</code></pre>
</blockquote>

<p>I found that, the code does not work on IE if the all of them is executed in 'file://' protocol, however, it is not the problem since its use case involved real web application.</p>

<p>I tried it once to include <strong><a href="http://www.google-analytics.com/urchin.js" rel="nofollow">http://www.google-analytics.com/urchin.js</a></strong> by google, but from one of web page, but it looks like it cannot request javascript file from different domain.</p>

<p>How we could dynamically add javascript, just like what above scripts does, but from another domain? </p>
