Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What's the preferred way to add a DOM ready handler? #747

Open
thanatos opened this issue Feb 3, 2017 · 1 comment
Open

What's the preferred way to add a DOM ready handler? #747

thanatos opened this issue Feb 3, 2017 · 1 comment

Comments

@thanatos
Copy link

thanatos commented Feb 3, 2017

learn.jquery.com's document ready page suggests,

Experienced developers sometimes use the shorthand $() for $( document ).ready(). If you are writing code that people who aren't experienced with jQuery may see, it's best to use the long form.

However, api.jquery.com's reference suggests,

jQuery offers several ways to attach a function that will run when the DOM is ready. All of the following syntaxes are equivalent:

  • $( handler )
  • $( document ).ready( handler )
  • $( "document" ).ready( handler )
  • $( "img" ).ready( handler )
  • $().ready( handler )

As of jQuery 3.0, only the first syntax is recommended; the other syntaxes still work but are deprecated.

These suggestions feel at odds with each other. Given the deprecation notice, it seems like learn.jquery.com's suggestion is outdated.

@AurelioDeRosa
Copy link
Member

Good catch, we didn't update the relevant text in the learn website. Do you want to submit a PR for this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants