jQuery holdReady() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
Core

Definition

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
  });
CallWhat 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

ParameterDescription
Step 1Call $.holdReady(true) in the <head> right after the jQuery script tag.
Step 2Load plugins or other async work (for example with $.getScript).
Step 3Call $.holdReady(false) when that work finishes — one release per hold.

Return Value

Return ValueDescription
See examplesCheck 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.

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).

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.

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.

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() Method

Learn how jQuery reports errors thrown inside ready handlers.

jQuery.readyException() Method tutorial →

CODETOFUN NEWS

Stay Ahead in Tech

Get the latest IT news, programming updates, and technology trends directly on your phone.

Your daily dose of tech, straight to your feed.

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