jquery / jquery/learn.jquery.com

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

Open
#747 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Chapter: jquery-core help wanted
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.