title: Why am I getting a jQuery is not defined error?
body: <p>I have to use an external js file in order to load jquery. The code from my js file is below: </p>
  
  <pre><code> document.write('&lt;script language="javascript" type="text/javascript" src="http://code.jquery.com/jquery-1.4.4.min.js"&gt;&lt;/script&gt;');
  
      (function($) {
          $(document).ready(function() {
              alert('it works!!');
          });
      })(jQuery);
  </code></pre>
  
  <p>In the firefox firebug console I see this error: "jQuery is not defined" and I think it is because the jQuery library is loaded after the $ function from my js file.</p>
  
  <p>Do you have any idea about how can I fix this? If I run the script from the firebug console everything works fine.</p>