There is an important difference, the first is a DOM ready handler, it waits until the document is ready and all elements can be accessed.
The second one is just an immediately invoked function expression, it executes immediately and does not wait for the document to be ready.
Both of them creates a local scope where the value of $
equals jQuery