jQuery.ready is a thenable (Promise-like object) that resolves when the document DOM is ready to manipulate (since jQuery 1.8). .ready() callbacks use this signal.
Syntax
Start with these common calls. Keep them short and readable.
jQuery
// Official pattern
$.when($.ready).then(function () {
// Document is ready
});
// Combine with Ajax
$.when($.getJSON("ajax/test.json"), $.ready)
.done(function (data) {
// DOM ready + JSON loaded
});
// Everyday callback form (related API)
$(function () { /* same ready moment */ });
Call
What it does
ready
Learn jQuery.ready: Promise-like thenable that resolves when the DOM is ready, $.when patterns, vs .ready(), examples, pitfalls, and FAQs.
Load jQuery before your script (CDN or local file), then wrap DOM work in $(function () { ... }) when needed.
Parameters
Parameter
Description
Step 1
Include jQuery before your script.
Step 2
Pass $.ready (same as jQuery.ready) to $.when() or Promise.resolve().
Step 3
In .then / .done, select elements and attach handlers.
Return Value
Return Value
Description
See examples
Check the examples below for what this API returns in common cases.
jQuery Examples
Example 1 — Official: $.when($.ready)
Wait for the document ready thenable, then update the page.
jQuery
$.when($.ready).then(function () {
// Document is ready.
$("p").text("The DOM is now loaded and can be manipulated.");
});
Wait with when.$.when resolves when that signal does.
Then run. Your handler can safely select and change elements.
Example 2 — Official Idea: Ready + Async Work
Wait until both a task and the DOM are ready before using the result.
jQuery
// Same idea as: $.when($.getJSON(url), $.ready)
var task = $.Deferred().resolve({ msg: "hello" }).promise();
$.when(task, $.ready).done(function (data) {
// Document is ready.
// Value from the async task is passed as `data`.
$("#out").text(data.msg);
});
Wrap the thenable.Promise.resolve accepts any thenable.
Chain .then. Native Promise style, same ready moment.
Supported path. Official jQuery 3.0 guidance for this object.
Frequently Asked Questions
jQuery.ready is a Promise-like object (thenable) on the jQuery namespace. It resolves when the document DOM is safe to manipulate — the same moment .ready() handlers run. Added in jQuery 1.8.
$(function(){ … }) is the common callback form (shorthand for .ready()). jQuery.ready is the underlying thenable you pass to $.when() or Promise.resolve(). Beginners usually use $(fn); jQuery.ready shines when combining ready with other async work.
Official pattern: $.when($.ready).then(function(){ /* DOM ready */ }); With Ajax: $.when($.getJSON(url), $.ready).done(function(data){ /* both finished */ }); Since jQuery 3.0 you can also use Promise.resolve($.ready).
As of jQuery 3.0, do not assume either. It is thenable — it has .then() and works with $.when and Promise.resolve(). Treat it as an opaque ready signal, not something to reject or extend.
jQuery.ready (and .ready()) fire when the HTML DOM is parsed — before images and other assets finish. The window load event waits for all assets. Use ready for DOM setup; use load when you need full resources (for example image sizes).
Yes. Handlers and $.when($.ready) still resolve even if your script runs late — unlike addEventListener('DOMContentLoaded') registered after the event already fired.