I saw there is an answered question about whether there is a difference between using $(document).ready(function(){})
and $(function(){})
(there isn't), but my question is which is the preferred syntax and why.
I've been using jQuery for about a year and have always used the $(document).ready()
syntax; but lately on SO and in some other places, I've seen the $(function())
syntax used more and more.
Is there a preferred syntax that you use and why do you use it? Do you use the shorter syntax solely to save a few characters?
Just a little more background, I'm currently starting a new app from the ground up and want to put some generally accepted best practices and standards in place.
Thanks in advance!