FAQ: jQuery Setup - .ready()


This community-built FAQ covers the “.ready()” exercise from the lesson “jQuery Setup”.

Paths and Courses
This exercise can be found in the following Codecademy content:

Web Development

Introduction to jQuery

FAQs on the exercise .ready()

Join the Discussion. Help a fellow learner on their journey.

Ask or answer a question about this exercise by clicking reply (reply) below!

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources? Head here.

Looking for motivation to keep learning? Join our wider discussions.

Learn more about how to use this guide.

Found a bug? Report it!

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!


According to the official jQuery .ready() documentation, the syntax suggested in this exercise has been deprecated and may be disabled in future versions: https://api.jquery.com/ready/

What I don’t understand is the recommended syntax does not include .ready() anywhere:

$(function() {
  //Handler for .ready() called.

The rest of the document is not helpful in explaining how .ready() is called without explicit inclusion in the code. Have they baked the .ready() method into all $() wrappers? I want to make sure I’m not missing some crucial detail when I use their recommended syntax.


DOMContentLoaded looks to be the driving event going forward. Needless, deprecated does not mean ‘not supported’. The language will be backward compatible for a good long time to come.


.ready() is not being deprecated - only certain syntax variants. The example I posted is the recommended syntax for the .ready() method. I can’t think of any argument to use deprecated syntax when there is an equivalent syntax that has much less chance of breaking down the road. The implementation (complete omission of the word “ready”) is confusing to me and I was hoping to get some more insight.

Also, the document advocates an advantage .ready() has over DOMContentLoaded: since it is only waiting for a condition (is the DOM loaded?), it can be called well after the page loads. However:

In contrast, a DOMContentLoaded event listener added after the event fires is never executed.

The document is not written very well, so I can see how someone might misinterpret it (I had to read it several times).


Please cite your source for this.