jQuery.holdReady(hold) (since 1.6) delays or releases jQuery’s document ready event. Pass true to hold, false to release one hold. It is deprecated since 3.2 but still works in jQuery 3.x.
Syntax
Start with these common calls. Keep them short and readable.
jQuery
// Deprecated (since 3.2) — call early, before ready fires
$.holdReady(true); // delay ready
$.holdReady(false); // release one hold
// Modern replacement
$.when($.ready, customPromise)
.then(function () {
// main code
})
.catch(function (error) {
// handle errors
});
Call
What it does
holdReady()
Learn jQuery.holdReady(): delay and release the document ready event, use multiple holds, migrate from the deprecated 3.2 API to $.when($.ready, promise).
Load jQuery before your script (CDN or local file), then wrap DOM work in $(function () { ... }) when needed.
Parameters
Parameter
Description
Step 1
Call $.holdReady(true) in the <head> right after the jQuery script tag.
Step 2
Load plugins or other async work (for example with $.getScript).
Step 3
Call $.holdReady(false) when that work finishes — one release per hold.
Return Value
Return Value
Description
See examples
Check the examples below for what this API returns in common cases.
jQuery Examples
Example 1 — Hold Until a Plugin Loads
Official pattern: hold, load a script, then release.
Hold. Ready is blocked even if the DOM is already parsed.
Register.$(function () { … }) queues the handler.
Wait. The timer stands in for async work.
Example 3 — Multiple Holds
Two true calls need two false calls before ready runs.
jQuery
$.holdReady(true);
$.holdReady(true);
$(function () {
$("#out").text("Ready finally runs");
});
$.holdReady(false); // still held
$.holdReady(false); // now ready can fire
After first release — still waiting
After second release → Ready finally runs
How It Works
Count up. Each true adds one hold.
Partial release. One false is not enough.
Clear. The last matching false clears the counter.
Frequently Asked Questions
jQuery.holdReady(hold) pauses or releases jQuery's document ready event. Pass true to delay ready handlers; pass false to release one hold. Added in jQuery 1.6 for dynamic script loaders that need plugins loaded before page init.
Yes. It was deprecated in jQuery 3.2. Prefer $.when($.ready, customPromise).then(...). It still works in jQuery 3.x but should not appear in new code.
Early in the document — typically in the head immediately after the jQuery script tag, before DOM ready fires. Calling holdReady(true) after ready already ran has no effect.
Yes. Each holdReady(true) increments an internal counter. Ready does not fire until every hold is released with a matching holdReady(false) and normal DOM ready conditions are met.
Use $.when($.ready, yourPromise).then(function(){ /* main code */ }).catch(function(err){ /* errors */ }). Build a Deferred or Promise for getScript, dynamic imports, or module loading, then compose it with $.ready.
$.ready is the thenable that resolves when ready fires. holdReady blocks that resolution until holds are released. While held, $(function(){}) callbacks wait even if the HTML DOM is already parsed.