When using $(document).ready why must it be in an anonymous function?
<p>I use document ready all the time, but I'm watching some tutorial videos to really KNOW whats going on instead of just knowing from typing it so much.</p>

<p>I had always put it in an anonymous function out of habit as thats how its always done, but now I see if its NOT in an anonymous function (say <code>alert();</code> for instance), it will execute NOT when the DOM is loaded but immediately when that javascript loads. It must be in an anonymous function for this to happen how its supposed to (when the whole page loads) and the event listeneter triggers that its 'ready'.</p>

<p>Why is this?</p>

<p>furthermore I often see something like function(i){}(i), what does this mean?</p>
