The jQuery.ready property is a thenable that resolves when the DOM is safe to manipulate. This tutorial covers the official jQuery.when patterns, how it relates to $(function(){}) and .ready(), combining ready with Ajax, and modern Promise.resolve usage in jQuery 3.0+.
01
Thenable
$.ready
02
Since 1.8
Added
03
$.when
Combine
04
DOM first
Not load
05
Late bind
Still runs
06
3.0+
Promise.resolve
Fundamentals
Introduction
jQuery code usually needs to wait until the browser has parsed the HTML before selecting elements, attaching events, or changing the DOM. The familiar shorthand $(function(){ ... }) registers a callback for that moment.
Under the hood, jQuery exposes jQuery.ready — a Promise-like object you can pass to jQuery.when() or native promise helpers. It resolves once the document is ready, letting you coordinate DOM setup with other asynchronous tasks such as $.getJSON() in a single .done() handler.
If you are new to jQuery, start with $(function(){}) for everyday page setup. Reach for jQuery.ready when you need promise-style composition — the patterns shown in the official jQuery documentation since version 1.8.
Concept
Understanding the jQuery.ready Property
jQuery.ready is not a function you call. It is a thenable — an object with a .then() method that fulfills when jQuery’s internal ready list fires. The .ready( handler ) method on collections uses this same mechanism to queue and run your callbacks.
As of jQuery 3.0, the documentation warns not to assume jQuery.ready is a jQuery.Deferred or a native Promise. Code should treat it as an opaque ready signal compatible with jQuery.when and Promise.resolve().
💡
Beginner Tip
jQuery.ready means “DOM is parsed and safe.” It does not wait for images, stylesheets, or iframes to finish loading — use $(window).on("load", fn) for that.
Foundation
📝 Syntax
Access the global ready thenable — no arguments:
jQuery
jQuery.ready
// or
$.ready
Official usage patterns
jQuery
// Pattern 1 — listen for document ready (jQuery 1.8+)
$.when( $.ready ).then(function () {
// Document is ready.
});
// Pattern 2 — wait for Ajax AND ready (official demo)
$.when(
$.getJSON( "ajax/test.json" ),
$.ready
).done(function ( data ) {
// Document is ready.
// Value of test.json is passed as data.
});
// Pattern 3 — jQuery 3.0+ with native Promise
Promise.resolve( $.ready ).then(function () {
// Document is ready.
});
Return value
A thenable object that resolves when the DOM is ready.
No value is passed to .then() handlers — the signal itself means “ready.”
Related callback API: $(function(){ ... }) and $(document).ready(fn).
Cheat Sheet
⚡ Quick Reference
Expression
Meaning
$.ready
Thenable — resolves when DOM is ready
$.when($.ready).then(fn)
Official ready listener (1.8+)
$(function(){ fn })
Beginner shorthand — same timing
$.when(ajax, $.ready).done(fn)
Wait for both Ajax and DOM
Promise.resolve($.ready)
Native Promise wrapper (3.0+)
$(window).on("load", fn)
All assets loaded — different event
Compare
📋 jQuery.ready vs $(fn) vs DOMContentLoaded
Three ways to run code when the DOM is parsed — jQuery ready helpers handle late registration.
$.when accepts one or more thenables. When $.ready resolves, your callback runs — equivalent timing to $(function(){}) but in promise style.
📈 Practical Patterns
Combine ready with Ajax, native Promises, shorthand callbacks, and late-loaded scripts.
Example 2 — Official Ajax + Ready Combined
Wait for JSON data and DOM ready before initializing the UI.
jQuery
$.when(
$.getJSON( "ajax/test.json" ),
$.ready
).done(function ( data ) {
// Document is ready.
// Value of test.json is passed as data.
$("#list").empty();
$.each( data.items, function ( i, item ) {
$("#list").append( "<li>" + item + "</li>" );
});
});
$.when waits for every argument to resolve. If Ajax finishes before the DOM, the handler still waits for $.ready — preventing $("#list") from running on a missing node.
Example 3 — Promise.resolve( $.ready ) (jQuery 3.0+)
Wrap the thenable in a native Promise for async/await or .then chains.
jQuery 3.0 documented Promise.resolve() as supported alongside $.when. This bridges jQuery ready timing with modern async code without assuming $.ready is a native Promise.
Example 4 — Equivalent $(function(){}) Shorthand
Official ready demo — the pattern most beginners use daily.
jQuery
// Recommended since jQuery 3.0
$(function () {
// Handler for .ready() called.
$("p").text("The DOM is now loaded and can be manipulated.");
});
// Equivalent long form
$(document).ready(function () {
// Same timing as above.
});
Both forms queue a handler on the same internal ready list that backs jQuery.ready. Use shorthand for simple init; use $.ready when composing with other async work.
Example 5 — Late Registration Still Runs
jQuery ready handlers fire even when registered after DOMContentLoaded — unlike raw event listeners.
jQuery
// Simulate script loaded after DOM is already parsed
setTimeout(function () {
$.when( $.ready ).then(function () {
console.log("jQuery ready still runs late");
});
// Native listener added too late — never fires if event passed
document.addEventListener("DOMContentLoaded", function () {
console.log("This often never runs when registered late");
});
}, 0);
jQuery ready still runs late
(late DOMContentLoaded listener silent)
How It Works
jQuery checks whether the document is already ready before scheduling handlers. If ready passed, queued callbacks run immediately on the next tick. That is why dynamically loaded jQuery bundles can still safely call $(fn).
Applications
🚀 Common Use Cases
Ajax + DOM gate — $.when($.getJSON(url), $.ready) before building UI.
Plugin initialization — ensure DOM exists before .append() or .on().
Promise pipelines — chain ready with other thenables in jQuery 3 apps.
Dynamic script tags — late-loaded jQuery still runs ready handlers.
Module bundlers — defer entry until Promise.resolve($.ready).
Testing — await ready before asserting on DOM fixtures.
🧠 How jQuery.ready Fits the Page Load Timeline
1
HTML parses
Browser builds the DOM tree from markup.
Parse
2
DOMContentLoaded
Native event fires — DOM safe, images may still load.
Event
3
$.ready resolves
jQuery runs queued .ready() handlers and fulfills jQuery.ready.
Ready
4
✅
Manipulate DOM
Select elements, bind events, run plugins — before full page load completes.
Important
📝 Notes
Added in jQuery 1.8 — still supported in jQuery 3.7.x.
Not the same as the removed event-handler overload of .toggle() or $(document).on("ready") (removed in 3.0).
Since jQuery 3.0, only $(handler) shorthand is recommended for callbacks — not $("img").ready(handler).
Do not attach window load listeners inside a ready handler expecting them to run if load already fired.
Related: jQuery.holdReady() can pause ready (advanced), jQuery.isReady reports state.
Place scripts at end of <body> or use defer — ready helps but clean HTML order still matters.
Compatibility
Browser Support
jQuery.ready works wherever jQuery runs. It normalizes ready behavior across browsers jQuery supports, including legacy environments where DOMContentLoaded was inconsistent.
✓ jQuery 1.8+
jQuery jQuery.ready
Supported in jQuery 1.x, 2.x, and 3.x. Use Promise.resolve($.ready) in jQuery 3.0+. Native DOMContentLoaded is available in all modern browsers for non-jQuery code.
100%With jQuery loaded
Google ChromeAll versions · Desktop & Mobile
Full support
Mozilla FirefoxAll versions · Desktop & Mobile
Full support
Apple SafariAll versions · macOS & iOS
Full support
Microsoft EdgeAll versions · Chromium & Legacy
Full support
Internet ExplorerIE 6+ · Legacy environments
Full support
OperaAll modern versions
Full support
jQuery.readyUniversal
Bottom line: Prefer $(function(){}) for simple pages. Use jQuery.ready with $.when when coordinating DOM timing and Ajax in one handler.
Wrap Up
Conclusion
jQuery.ready is the promise-style face of jQuery’s document-ready system — a thenable that resolves when the DOM is safe to touch. Pair it with jQuery.when to wait for Ajax and markup together, or wrap it with Promise.resolve in modern async code.
For everyday pages, $(function(){}) remains the clearest choice. Know jQuery.ready when you need composition — and remember it signals DOM ready, not full page load.
Use $.when(ajax, $.ready) when both must finish first
Prefer Promise.resolve($.ready) in async/await code (3.0+)
Use $(window).on("load") when you need image dimensions
Keep ready handlers focused — defer heavy work if needed
❌ Don’t
Assume $.ready is a native Promise or Deferred
Confuse DOM ready with window load
Use deprecated $("img").ready(fn) syntax (jQuery 3.0+)
Register window load inside ready expecting it always to fire
Skip ready and manipulate DOM before elements exist
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about jQuery.ready
The thenable behind document-ready in jQuery.
5
Core concepts
✅01
$.ready
Thenable
API
🔄02
$.when
Compose
Pattern
fn03
$(fn)
Shorthand
Daily
DOM04
Not load
Earlier
Timing
3.005
Promise
resolve
Modern
❓ Frequently Asked Questions
jQuery.ready is a Promise-like object (thenable) on the global jQuery namespace. It resolves when the document DOM is safe to manipulate — the same moment jQuery's .ready() handlers run. Added in jQuery 1.8.
$(function(){ fn }) is shorthand for $(document).ready(fn) — you pass a callback. jQuery.ready is the underlying thenable you can 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 is ready */ }); For Ajax plus ready: $.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(), but its internal type may change. Treat it as an opaque ready signal, not a Deferred you should .reject() or extend.
jQuery.ready (and .ready()) fire when the HTML DOM is parsed and ready — before images and other assets finish loading. The window load event waits for all assets. Use ready for DOM setup and event handlers; use $(window).on('load') when you need image dimensions or full page resources.
Yes. jQuery queues .ready() callbacks and resolves jQuery.ready even when your script runs late — unlike addEventListener('DOMContentLoaded') registered after the event already fired. That late-binding behavior is a major reason jQuery ready helpers remain convenient.
Did you know?
Before jQuery 1.8, developers only had callback-style .ready(). Adding jQuery.ready as a thenable let jQuery participate cleanly in $.when pipelines alongside $.ajax and $.getJSON. jQuery 3.0 went further by documenting Promise.resolve($.ready) — bridging jQuery’s ready system with native Promises without locking internal implementation to either Deferreds or browser Promise objects.