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.
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 alert();
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'.
Why is this?
furthermore I often see something like function(i){}(i), what does this mean?