Is there any catch/gotcha in this JavaScript boilerplate?
<p>I'm developing a website with jQuery and organize code into several script files.</p>

<p>If I didn't get it wrong, there's a best practice of organizing your code like this boilerplate (which creates a separated scope and set the <code>undefined</code> value correctly):</p>

<pre><code>(function($, undefined) {
    $(document).ready(function() {
        // code here
    });
})(jQuery);
</code></pre>

<p>In my case, I will also rely on some external configuration outputted by some server-side script, say it is stored as global variable <code>site_config</code>. So currently my script boilerplate is:</p>

<pre><code>(function(window, undefined) {
    var document = window.document;
    var $ = window.jQuery;
    var config = window.site_config;

    // equivalent to $(document).ready(function() {...
    $(function() {
        // code here using `config`
    });
})(window);
</code></pre>

<p>So my question is: is there any catch/gotcha in this boilerplate?</p>

<p>Specifically:</p>

<ol>
<li>is it OK to pass in <code>window</code> explicitly? (suppose the wrapper function is in global scope)</li>
<li>should I use <code>window.document</code> or <code>jQuery.document</code>? If both are wrong, how to reference correctly?</li>
</ol>
