Bitcoin Forum
December 08, 2016, 10:19:06 PM *
News: To be able to use the next phase of the beta forum software, please ensure that your email address is correct/functional.
 
   Home   Help Search Donate Login Register  
Pages: [1]
  Print  
Author Topic: jquery document.ready  (Read 821 times)
payb.tc
Hero Member
*****
Offline Offline

Activity: 812



View Profile
November 13, 2011, 09:10:25 AM
 #1

if these are 100% equivalent, why on earth would anyone ever use the longer version?

$(document).ready(handler)
$(handler)

i really wonder.

Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1481235546
Hero Member
*
Offline Offline

Posts: 1481235546

View Profile Personal Message (Offline)

Ignore
1481235546
Reply with quote  #2

1481235546
Report to moderator
1481235546
Hero Member
*
Offline Offline

Posts: 1481235546

View Profile Personal Message (Offline)

Ignore
1481235546
Reply with quote  #2

1481235546
Report to moderator
1481235546
Hero Member
*
Offline Offline

Posts: 1481235546

View Profile Personal Message (Offline)

Ignore
1481235546
Reply with quote  #2

1481235546
Report to moderator
captainteemo
Full Member
***
Offline Offline

Activity: 145


View Profile
November 15, 2011, 05:02:46 AM
 #2

one waits for the page to complete loading, then do actions in the background. if you put this at the top of a page, with a slow thing, it waits for the page to finish
other fires wherever it hits (blocking, non-async) if you put this at the top of a page, it won't finish rendering until it returns

btc_artist
Full Member
***
Offline Offline

Activity: 154


Bitcoin!


View Profile WWW
November 15, 2011, 07:24:18 AM
 #3

if these are 100% equivalent, why on earth would anyone ever use the longer version?

$(document).ready(handler)
$(handler)

i really wonder.


As far as I know, nobody uses the longer version.  It *is* self-documenting though, which is a plus I guess.

BTC: 1CDCLDBHbAzHyYUkk1wYHPYmrtDZNhk8zf
LTC: LMS7SqZJnqzxo76iDSEua33WCyYZdjaQoE
payb.tc
Hero Member
*****
Offline Offline

Activity: 812



View Profile
November 15, 2011, 09:46:30 AM
 #4

one waits for the page to complete loading, then do actions in the background. if you put this at the top of a page, with a slow thing, it waits for the page to finish
other fires wherever it hits (blocking, non-async) if you put this at the top of a page, it won't finish rendering until it returns

no, they are functionally identical... both only fire when the 'document' is 'ready'... one is just a shorter way of writing it, but i've seen hundreds of examples all over the web that has the longer version in it.
btc_artist
Full Member
***
Offline Offline

Activity: 154


Bitcoin!


View Profile WWW
November 15, 2011, 08:27:51 PM
 #5

So the answer to your question is probably that people just copy example they see (the long version) and are oblivious to the fact that there's a more concise way to do it.

BTC: 1CDCLDBHbAzHyYUkk1wYHPYmrtDZNhk8zf
LTC: LMS7SqZJnqzxo76iDSEua33WCyYZdjaQoE
Pages: [1]
  Print  
 
Jump to:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!