title: jQuery.getScript loads javascript file before DOM
body: <p>Using ajax to load my content dynamically. I need to load a javascript file after I click on a button:</p>
  
  <pre><code>&lt;a id="element" href="http://example.com/test"&gt;button&lt;/a&gt;
  </code></pre>
  
  <p>But the script below loads the javascript file before the DOM has been loaded.
  How can I solve this?</p>
  
  <pre><code>$("#element").click(function () {
    jQuery.getScript("example.com/jsfile.js?ver=0.9");  
  }); 
  </code></pre>
  
  <p>screenshot of firebug: <a href="http://img607.imageshack.us/img607/1630/4mu7.png" rel="nofollow">http://img607.imageshack.us/img607/1630/4mu7.png</a></p>
  
  <p>The 1st row is the loaded javascript file that's called via the above function and the 3rd row is the page that's being loaded.</p>