In most of the videos, I see expert JQuery developers writing complete code for the ready event eg:
$(document).ready(function(){
//.....
});
rather than its shortcut:
$(function(){
//.....
});
Is there any particular down side to using shortcut method?
Edit:
Jquery documentation says:
shortcut not recommended
That’s my question, why is it not recommended? Should we ever use it in our projects?
Good question… sometimes these shortcuts breed as much confusion as convenience.
Per the jQuery docs:
EDIT
$().ready(handler)is not recommended in the documentation and, in the latest version of jQuery, will not work.In older versions of jQuery,
$(document)and$()were equivalent. Per the jQuery site, this is no longer the case