JS load order with jQuery on load inside a function that executes immediately
<p>Can you do this?</p>

<pre><code>var myFunction = function(){
    $(function(){
        // jQuery code here
        $("#myField").hide();
    })    
}();
</code></pre>

<p>I had some code like this which worked fine almost everywhere but then I discovered it only worked about 80% of the time in FF 9.0.1. The fix was to do this:</p>

<pre><code>var myFunction = function(){
    $(function(){
        // jQuery code here
        $("#myField").hide();
    })    
};
myFunction();
</code></pre>

<p>Now I'm a bit puzzled why this was necessary</p>

<p>EDIT:
I can see this is a bit confusing. Maybe what I should have done would have been this instead:</p>

<pre><code>var myFunction = function(){ 
    // jQuery code here
    $("#myField").hide();       
};

$(function(){
    myFunction();
});
</code></pre>
