jQuery holdReady() Method

Beginner
7 min read
Updated: Oct 2026
5 examples
Live preview

What Is jQuery.holdReady()?

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.

Remember
// 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
  });
NeedUse
New code$.when($.ready, promise).then(fn)
Legacy delay$.holdReady(true) ⚠
Legacy release$.holdReady(false) ⚠
DOM ready only$(function () { … })
Load a script$.getScript()

How to Use holdReady()

Call early, pair every hold with a release, and prefer $.when for new work.

  1. Call $.holdReady(true) in the <head> right after the jQuery script tag.
  2. Load plugins or other async work (for example with $.getScript).
  3. Call $.holdReady(false) when that work finishes — one release per hold.
  4. Register ready handlers with $(function () { … }) as usual; they wait while held.
  5. In new code, replace the global switch with $.when($.ready, promise).
PieceRequired?Role
holdYestrue = delay · false = release one
TimingCriticalMust run before ready already fired
CounterImplicitEach true needs a matching false
Return—undefined

Pseudocode

Pseudocode
call $.holdReady(true) early
    → holdCount = holdCount + 1
    → ready handlers wait

load plugin / async work

call $.holdReady(false)
    → holdCount = holdCount - 1

when holdCount === 0 and DOM is ready:
    fire jQuery ready
    run all $(function () { ... }) handlers

if holdReady(true) after ready already fired:
    no effect

modern path:
    $.when($.ready, customPromise).then(main)

Cheat Sheet

Quick facts for reading or migrating legacy holdReady code.

TopicDetail
Hold$.holdReady(true) ⚠
Release$.holdReady(false)
Modern$.when($.ready, promise).then(fn)
Since1.6 · deprecated 3.2
Returnsundefined
When to callImmediately after loading jQuery
Too late?No effect if ready already fired
Multiple holdsNeed matching number of releases

Live Preview

This page’s ready event already fired, so the demo simulates hold/release timing and the modern $.when pattern.

Simulation only — use Try It Yourself for a real early holdReady(true) in <head>.

Result
Ready — pick an action and click Run.

jQuery Examples

Short demos of the legacy API and the modern replacement. Prefer $.when for new projects.

Example 1 — Hold Until a Plugin Loads

Official pattern: hold, load a script, then release.

jQuery
$.holdReady(true);
$.getScript("myplugin.js", function () {
  $.holdReady(false);
});

$(function () {
  MyPlugin.init();
});
Try It Yourself

How It Works

  1. Hold. $.holdReady(true) blocks ready early in the page.
  2. Load. $.getScript fetches the plugin asynchronously.
  3. Release. The callback calls $.holdReady(false).
  4. Init. The ready handler can safely call MyPlugin.init().

Example 2 — Delayed Ready Handler

A ready callback waits until you release the hold.

jQuery
$.holdReady(true);

$(function () {
  $("#out").text("Ready handler ran after release");
});

setTimeout(function () {
  $.holdReady(false);
}, 800);
Try It Yourself

How It Works

  1. Hold. Ready is blocked even if the DOM is already parsed.
  2. Register. $(function () { … }) queues the handler.
  3. Wait. The timer stands in for async work.
  4. Release. false lets the queued handler run.

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
Try It Yourself

How It Works

  1. Count up. Each true adds one hold.
  2. Partial release. One false is not enough.
  3. Clear. The last matching false clears the counter.
  4. Fire. Ready runs when the counter hits zero and the DOM is ready.

Example 4 — Modern $.when($.ready, …)

Official replacement: wait for ready and a custom promise together.

jQuery
var pluginReady = $.Deferred();

setTimeout(function () {
  window.MyPlugin = { init: function () { return "ok"; } };
  pluginReady.resolve();
}, 400);

$.when($.ready, pluginReady).then(function () {
  $("#out").text("Init: " + MyPlugin.init());
});
Try It Yourself

How It Works

  1. Promise. A Deferred stands in for async plugin load.
  2. Compose. $.when waits for $.ready and that promise.
  3. Then. Main code runs only when both are done.
  4. Prefer. This is the recommended pattern since jQuery 3.2.

Example 5 — Hold After Ready Has No Effect

Calling holdReady(true) too late does nothing.

jQuery
$(function () {
  $("#out").append("Ready already ran. ");
  $.holdReady(true);
  $("#out").append("holdReady(true) after ready — no effect. ");
  $(function () {
    $("#out").append("Inner handler still runs immediately.");
  });
});
Try It Yourself

How It Works

  1. Ready first. The outer handler means ready already fired.
  2. Late hold. holdReady(true) cannot rewind ready.
  3. Immediate. New ready callbacks run right away.
  4. Lesson. Always hold in <head> before ready.

Edge Cases & Pitfalls

Watch for these when reading or migrating holdReady code.

deprecated

Do not use in new code

Deprecated since 3.2. Prefer $.when($.ready, promise).

timing

Must call before ready

A late holdReady(true) has no effect. Put it in <head> after jQuery.

balance

Unbalanced holds hang ready

Every true needs a false. A missing release means ready never fires.

errors

Failed loads must still release

If getScript fails, still call holdReady(false) (or reject a promise) so the page does not wait forever.

Browser Support

jQuery.holdReady() has been part of jQuery since 1.6. It is deprecated since 3.2 but still functional in jQuery 3.x. Prefer $.when($.ready, …) for new projects.

✓ Deprecated · jQuery 1.6+

jQuery.holdReady()

Works wherever your loaded jQuery version runs. Treat it as a legacy global switch — migrate to explicit promises when updating code.

100% With jQuery 3.x
Google Chrome All versions · Desktop & Mobile
Full support
Mozilla Firefox All versions · Desktop & Mobile
Full support
Apple Safari All versions · macOS & iOS
Full support
Microsoft Edge All versions · Chromium & Legacy
Full support
Internet Explorer IE 6+ · Legacy environments
Full support
Opera All modern versions
Full support
holdReady Legacy API

Bottom line: Safe in legacy loaders. For new apps, wait with $.when($.ready, customPromise) instead of holding the global ready event.

Performance Notes

ApproachCostBest for
Short hold + small pluginCheapLegacy loaders
$.when($.ready, promise)CheapModern compose of ready + async
Long / forgotten holdExpensive (UX)Avoid — page init never starts

Holding ready does not slow the network by itself — it delays your init code. Keep holds short and always release them.

Key Takeaways

  • Role: delay jQuery ready until plugins or scripts finish loading.
  • Migrate: $.when($.ready, promise).then(fn) — preferred since 3.2.
  • Timing: call holdReady(true) early — too late does nothing.
  • Balance: every true needs a matching false.

One line: holdReady is a deprecated global pause for ready — use $.when($.ready, …) instead.

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.

Next: jQuery.readyException()

Learn how jQuery reports errors thrown inside ready handlers.

readyException tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

8 people found this page helpful