How should I initialize jQuery?

Posted by Reigel on Stack Overflow See other posts from Stack Overflow or by Reigel
Published on 2010-02-07T04:16:10Z Indexed on 2010/05/05 4:58 UTC
Read the original article Hit count: 179

Filed under:

I have seen this (I'm also using it):

$(document).ready(function(){
   // do jQuery
})

and also this (I have tried lately):

(function(){
   // do jQuery
})(jQuery)

both works fine.
My question is what is the difference of the two ( except on how it looks ).
Which one is more proper to use?.
Can you give me some pro's and con's for each?
Is there also another way of doing this?
(also help me with the title above. SO suggested, "The question you're asking appears subjective and is likely to be closed.")
Thanks everyone.

© Stack Overflow or respective owner

Related posts about jQuery