October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run ScanOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk3 min

Why `requestIdleCallback` Can Wait 40 Seconds—or Longer—for “Idle”

A 40-second wait is possible, but it is not an API limit. Understand browser idle scheduling, timeouts, callback deadlines, and practical fallbacks.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

A background task waiting 40 seconds for requestIdleCallback is plausible—but 40 seconds is an illustrative scenario, not a built-in limit or a universal measured result. The browser schedules this API when it considers the main thread idle; without a timeout, a busy page can keep postponing the callback with no guaranteed maximum wait.

Why can requestIdleCallback take so long?

requestIdleCallback asks the browser to run low-priority JavaScript during a period when it has spare time. It does not start a countdown, reserve time on the main thread, or promise when the callback will run. The browser decides whether a suitable idle period exists.

As an Amazon Associate I earn from qualifying purchases.

The W3C Web Performance Working Group’s May 21, 2025 Working Draft says that under heavy load, a user agent may have no idle CPU time and may postpone callbacks for a potentially unbounded period. That is why the title’s 40-second wait is possible as a scenario, but should not be read as an API guarantee or a published benchmark. W3C requestIdleCallback Working Draft

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

What do the callback’s deadline fields tell you?

The callback receives an IdleDeadline object. Its fields help you make a scheduling decision, but neither guarantees that the callback ran at an ideal moment nor makes a large chunk of work safe.

  • timeRemaining() estimates how much time is left in the current idle period. Use it to decide whether to start or continue a small unit of work.
  • didTimeout is true when the callback is running because its timeout expired, rather than because an idle period was available.

See MDN’s references for IdleDeadline and Window.requestIdleCallback().

What does a timeout change?

Passing a positive timeout gives the browser an escape from indefinite postponement: once the specified delay expires, the callback is queued even if running it could harm performance. A timeout is therefore a bound on when the callback is queued, not a promise that it will run in an idle slot or exactly at the requested time. Use it only when the cost of running during a busy period is acceptable.

requestIdleCallback(processChunk, { timeout: 2000 });

When a timeout causes execution, check deadline.didTimeout and keep the work short. If more remains, schedule another chunk rather than trying to finish everything in one callback.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Should this work wait, or must it finish?

The key decision is whether completion is mandatory, how long the task can safely wait, and what happens if it runs while the page is busy. Idle scheduling fits work that can be deferred or skipped; it should not be the only path for work that has to complete.

Task type Scheduling approach What to account for
Optional or deferrable work, such as cache pruning or precomputation Use requestIdleCallback and process small chunks. The callback may be delayed; make it safe to postpone or skip.
Required work that can continue in pieces Use a scheduling approach that yields between chunks; consider scheduler.yield() for work that must continue while allowing the browser to handle input and painting. Do not assume scheduler.yield() has uniform cross-browser support; verify support for the browsers you target.
Work that must be attempted when the page exits Provide a separate page-exit path, such as handling pagehide and attempting delivery with navigator.sendBeacon(). This is an implementation pattern, not a guarantee that data will always be delivered.

A practical draft-saving design, for example, can use idle time for routine, deferrable work while keeping a separate page-exit attempt. That avoids making a potentially delayed idle callback the only route to handling an important event.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

How should you handle browser support?

MDN currently classifies requestIdleCallback as limited availability and not Baseline. Check for it before use, and decide what should happen when it is missing.

if ('requestIdleCallback' in window) {
  window.requestIdleCallback(processChunk);
} else {
  window.setTimeout(processChunk, 1);
}

This fallback preserves a way to run the callback, but setTimeout cannot detect whether the main thread is idle. It is a timer-based fallback, not equivalent idle scheduling. For required work, make sure the fallback and surrounding application logic still provide a completion path.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

How to keep idle work from becoming a performance problem

  • Break work into small chunks instead of doing an entire job in one callback.
  • Use timeRemaining() as an estimate when deciding whether to continue a chunk; reschedule remaining work.
  • Check didTimeout so you can distinguish timeout-driven execution from a callback run during idle time.
  • Set a timeout only when the task’s delay matters and its impact during a busy period is acceptable.
  • Feature-detect the API and provide a deliberate fallback rather than assuming every browser supports it.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.