what is difference between
$(function(){ });
and
$(document).ready(function() { });
I suggest you read this. As you can see
All three of the following syntaxes are equivalent: $(document).ready(handler) $().ready(handler) (this is not recommended) $(handler)
All three of the following syntaxes are equivalent:
$(document).ready(handler)
$().ready(handler) (this is not recommended)
$(handler)
So it's up to you and to what you prefer.