Is there a difference between this:
$(document).ready(function() {
and this:
$().ready(function() {
Is there a difference between this:
$(document).ready(function() {
and this:
$().ready(function() {
according to jquery documentation they are the same.
All three of the following syntaxes are equivalent:
$(document).ready(handler)
$().ready(handler) // this is not recommended
$(handler)
i personally feel using $(document).ready(handler)
makes it more readable though.
They both are equivalent but the later one is not recommended per jQuery docs.
If I am not completely mistake, the first one is what you wanna use in any case (when using non-intrusive JS). The second one might even work (not tested) but if it does it will certainly be slower, as jQuery would have to detect the object that is loaded and upon which to run the denoted functon.
First, it has nothing to do with PHP, that's javascript code (using the jQuery library). I retagged your question accordingly.
Now, these 3 variants do the same thing (attach an event handler to the DOMLoaded event):
$(function(){});
$(document).ready(function(){});
$().ready(function(){});
The third one is not recommended, according to jQuery docs.