1

Possible Duplicates:
What is the difference between $(document).ready(function() and $(function() ?
What is the difference between these jQuery ready functions?

Furthermore, if they perform the same purpose, how does $(function(){ // js to run }) translate to $(document).ready()?

Community
  • 1
  • 1
dangerChihuahua007
  • 20,299
  • 35
  • 117
  • 206
  • Wow, thanks. I need to search more thoroughly. – dangerChihuahua007 Jan 23 '12 at 17:01
  • 1
    p.s; in answer to part II of your question (how do they map); [see here](https://github.com/jquery/jquery/blob/255460e4836e86b86f48dd5b7d2a2cbf3f996de2/src/core.js#L174) – Matt Jan 23 '12 at 17:02
  • $(function(){ does perform faster. But I cant explain the seasons for it. $.fn.ready() is faster still – atmd Jan 23 '12 at 17:03
  • 1
    Thanks! Essentially, if the factory function $() receives a function, the function is bound to the ready event. If $() receives a string, jQuery parses it as a selector. – dangerChihuahua007 Jan 23 '12 at 17:05

1 Answers1

1

they both do exactly the same thing.

Baz1nga
  • 15,485
  • 3
  • 35
  • 61