Course contentsShow
← JavaScript
Lesson 1206 of 2,72327. The Event LoopFree lesson

Minimum Delay Guarantees

Discover that browsers enforce a minimum ~4ms delay and why delays aren't exact timing guarantees.

Minimum Delay Guarantees

What you'll learn: You'll discover that browsers enforce a minimum delay on timers and why setTimeout delays aren't exact timing promises.

Why Delays Aren't Exact

When you set a setTimeout with a delay, you might expect it to run exactly after that time. But browsers impose a minimum delay of approximately 4 milliseconds for nested timers or timers that have already fired several times. This is a performance and battery optimization built into the HTML standard.

Even a setTimeout(callback, 0) won't run instantly—it gets queued in the Task Queue and must wait for the call stack to clear and all microtasks to finish first. Add the 4ms minimum on top of that, and you see why "zero delay" is a bit of a misnomer.

Real-World Impact

console.log('Start');

setTimeout(() => {
  console.log('First timer');
}, 0);

setTimeout(() => {
  console.log('Second timer');
}, 1);

console.log('End');

Even though the second timer specifies 1ms, both timers will likely fire around the same time (roughly 4ms+) because the browser rounds up to its minimum threshold. The order is predictable (first timer, then second), but neither runs at their "requested" time.

Think of It Like Shipping

If you request "same-day delivery" at 11:59 PM, the package still won't arrive until the next available delivery window—probably tomorrow morning. The delay you specify is a minimum, not a guarantee, and the system has its own constraints about when it can actually deliver.

Key Takeaway: Browsers enforce a ~4ms minimum delay on timers, and the delay you specify is a minimum wait time, not a precise schedule—never rely on setTimeout for exact timing.