It's useless
This form is not useful at all:
$(function($) {
});
It will work ONLY if there are no other libraries that could override $
(e.g. prototype).
How it could be useful
Since jQuery passes itself as the first argument to the DOM ready event handler function, this is how you could make good use of it:
jQuery(function($) {
// this === document
// $ === jQuery
});
The proof of this behaviour can also be found in the source:
readyList.resolveWith( document, [ jQuery ] );
It maps this
to document
and the first argument to your ready function to jQuery
. The reason why the code looks a bit non-obvious is because the ready event is handled using Deferred
.
The equivalent
The somewhat equivalent notation is this:
(function($) {
$(function() {
}
}(jQuery));
This would be preferred if you're doing more things outside of the ready handler, which actually happens more often than you think.