jquery / jquery/learn.jquery.com
What's the preferred way to add a DOM ready handler?
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 915
- Forks
- 471
- PR merge metrics
- No merged PRs in 30d
Description
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by comparing the linked learn.jquery.com document-ready page with the api.jquery.com ready reference and verify the current jQuery guidance. Done means the Learning Center and API reference no longer give conflicting recommendations about DOM ready handlers.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100