title: Document.ready in external files?
body: <p>I am referencing JavaScript as follows on an HTML page:</p>
  
  <pre><code>&lt;script type="text/javascript" src="http://code.jquery.com/jquery-1.6.1.min.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript" src="http://code.jquery.com/mobile/1.0b1/jquery.mobile-1.0b1.min.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false&amp;amp;region=GB"&gt;&lt;/script&gt;
  &lt;script type="text/javascript" src="js/shared.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript"&gt;
  $('document').ready(function() {   
      // In-page code: call some functions in shared.js
  });
  &lt;/script&gt;
  </code></pre>
  
  <p>The functions defined in shared.js are not wrapped inside <code>$('document').ready</code>. So:</p>
  
  <ol>
  <li><p>Is it safe to assume that functions defined in <code>shared.js</code> are available to the "in-page code"?</p></li>
  <li><p>If I pull out the in-page code into a separate file called <code>local.js</code> (keeping it wrapped in <code>$('document').ready</code>), is it still safe to assume that functions defined in <code>shared.js</code> are available?</p></li>
  <li><p>Finally, is the fact that I'm not wrapping shared.js inside <code>$('document').ready</code> a problem? I'm finding that if I do wrap it, its functions are no longer available to the in-page code. </p></li>
  </ol>
  
  <p>The reason for question 3 is that I'm hitting this problem: <a href="https://stackoverflow.com/questions/6547657/uncaught-typeerror-property-is-not-a-function-after-page-has-loaded">Uncaught TypeError: Property ... is not a function - after page has loaded</a></p>
  
  <p>and wondering if it is something to do with how I've organised my code. </p>
  
  <p>UPDATE: Thanks for the answers. It's now clear that using <code>$('document').ready</code> in shared.js would remove those functions from global scope. However, I just want to clarify the original question in point 3. </p>
  
  <p>Can I assume that if I do the following:</p>
  
  <ul>
  <li>inside my in-page code, loaded inside <code>$('document').ready</code>, call a function from shared.js</li>
  <li>have the function in shared.js refer to jQuery, Google Maps, or elements on my page</li>
  </ul>
  
  <p>there will be no problems?</p>
  
  <p>In other words, is it safe to assume that the page will have loaded by the time the functions inside <code>shared.js</code> are called, even if I'm not wrapping everything in that file inside <code>$('document').ready</code>?</p>