What exactly does !function ($){...}(window.jQuery) do?
<p>I'd like to know exactly what's going on here. I know what <code>$(document).ready(function() {...});</code> does and when it comes into effect. Same goes for <code>jQuery(function($) {...}</code>.</p>

<p>But what does this do?</p>

<pre><code>!function ($) {
  $(function(){
    var $window = $(window)
    //normal jquery stuff
  })
}(window.jQuery)
</code></pre>

<p>Is it loaded when jQuery is loaded instead of when the document is 'ready'?</p>
