When you pass zero to setTimeout, you’re asking JavaScript…
““When you pass zero to setTimeout, you’re asking JavaScript to run your timeout handler as soon as it possibly can — and this leads to your handler running as frequently as it possibly can.””
About This Quote
This interpretation was drafted with AI assistance. It is one reading of the quote, not the author's own explanation.
Setting zero delay in setTimeout causes the callback to execute as fast as the event loop permits, often leading to excessive, uncontrolled executions.
In simple terms: Zero delay makes the function run as often as possible.
Avoid zero delay; use requestAnimationFrame or throttling.
Themes
Mood
Type
When to use this quote
- UI animations
- data polling
- real‑time updates
- debounce implementations
Key Concepts
Questions to Reflect On
- Do you need that frequency?
- Could a lower frequency suffice?
Zero delay can still block the main thread and cause jank.