Tagged articles
setTimeout
25 articles · Page 1 of 1
The article explains how the browser’s single‑threaded nature makes long JavaScript tasks block rendering, outlines the timing issues of setTimeout, introduces requestAnimationFrame for visual sync, and shows how requestIdleCallback can safely schedule low‑priority work during idle periods.
Browser APIsJavaScriptrequestAnimationFrame
0 likes · 4 min read

This article examines the inefficiencies of traditional setInterval polling and presents three intelligent alternatives—using recursive setTimeout, applying exponential backoff, and leveraging the Page Visibility API—while providing code samples and highlighting their benefits over naive polling.
Frontend DevelopmentJavaScriptPage Visibility API
0 likes · 6 min read

Using setTimeout(fn, 0) tricks the JavaScript event loop to downgrade heavy tasks to asynchronous callbacks, freeing the main thread for UI rendering and user interactions, and the article explains the underlying mechanics, practical examples, and modern alternatives like requestAnimationFrame, queueMicrotask, and Web Workers.
JavaScriptasynchronousevent-loop
0 likes · 10 min read

This article explains the underlying browser mechanisms that cause page jank when creating millions of DOM elements, analyzes the event loop, rendering pipeline, macro‑ and micro‑tasks, and presents practical solutions such as setTimeout, requestAnimationFrame, MessageChannel, and requestIdleCallback to keep the UI responsive.
DOMJavaScriptRendering
0 likes · 16 min read

While setTimeout is a common JavaScript timer, its limited precision and throttling in inactive tabs can cause issues; this article presents seven more reliable alternatives—including requestAnimationFrame, setInterval, requestIdleCallback, Web Workers, Promise/async‑await, Web Animations API, and Intersection Observer—each with key advantages and usage examples.
JavaScriptTimerssetTimeout
0 likes · 5 min read

This article explains the fundamentals and execution order of JavaScript's setTimeout and setInterval functions, discusses their parameters and return values, demonstrates why setTimeout is asynchronous, shows how to cancel timers, and provides a custom recursive setTimeout solution that mimics setInterval behavior.
JavaScriptTimerfrontend
0 likes · 12 min read

Chrome 129’s new scheduler.yield() lets developers pause long‑running JavaScript loops without the 4 ms minimum delay or queue‑end placement of setTimeout(), cutting execution time from ~17 s to ~5.6 s while keeping the page responsive and preserving task priority.
ChromeFront-endJavaScript
0 likes · 10 min read

This article curates key frontend topics—including micro‑frontend challenges, precise setTimeout usage, object emptiness checks, project refactoring strategies, React Fiber architecture, and Facebook's StyleX styling system—providing concise explanations and practical guidance for modern web development.
React FiberStyleXfrontend
0 likes · 3 min read


58 TechMay 26, 2022 · Frontend Development
This article examines the challenges of timer precision in front‑end scenarios such as e‑commerce flash sales, explains the limitations of native setInterval and setTimeout, and introduces a frame‑based timer using requestAnimationFrame, requestIdleCallback and compensation strategies to achieve high‑accuracy scheduling.
JavaScriptTimersperformance
0 likes · 19 min read

This article explores why the native setTimeout cannot achieve a true 0 ms delay, presents a postMessage‑based zero‑timeout implementation, and compares several asynchronous JavaScript techniques—including queueMicrotask, async/await, and MessageChannel—showing their performance advantages over setTimeout.
JavaScriptMessageChannelMicrotask
0 likes · 7 min read


ByteFEJun 10, 2021 · Frontend Development
This article explains why browsers enforce a minimum 4 ms delay for nested setTimeout calls, demonstrates how to bypass it using window.postMessage to create a true zero‑delay timer, and compares the performance of both approaches with detailed experiments and visualizations.
JavaScriptPostMessagesetTimeout
0 likes · 10 min read

This article explains the various ways browsers interpret the numeric value zero in JavaScript timers, numeric comparisons, type coercion, and CSS properties such as font-size, width, height, line-height, and transform, providing code examples and cross‑browser observations.
CSSJavaScriptZeRO
0 likes · 10 min read
![Understanding How Browsers Handle Zero: setTimeout, +0/-0, +[], font-size, width/height, line-height, and transform](https://wsrv.nl/?url=http%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_jpg%2FWIlEZDpnCZHSsucBydlMRODacM9SqxVWDibhkkTJricYWN384icERlSua19kj4tF9JfZcyRlEcentlYAVgWuLTicIw%2F0%3Fwx_fmt%3Djpeg)
Using setInterval for repeated tasks in JavaScript can lead to unhandled errors, ignore network latency, and provide no guarantee of execution timing, causing request overloads and missed intervals; replacing it with setTimeout and dynamic scheduling ensures more reliable, controlled, and error‑resilient timing behavior.
JavaScriptTimerssetInterval
0 likes · 5 min read

The article explains JavaScript's single‑threaded, event‑loop based asynchronous model, demonstrates how setTimeout’s imprecise timing can cause unexpected behavior in a jQuery Ajax timeout scenario, and offers practical guidance to avoid relying on exact timer scheduling.
AJAXasyncevent-loop
0 likes · 8 min read

Discover how a playful setTimeout‑based sorting trick leverages JavaScript’s event loop to produce correct ordering, while explaining the core concepts of synchronous vs asynchronous tasks, the execution stack, task queue, and why this method isn’t practical for large datasets.
JavaScriptSorting Algorithmasynchronous
0 likes · 6 min read

This concise JavaScript example demonstrates how to employ setTimeout to schedule a console.log call that prints a colored 'Good night, friends~' message after a two‑hour delay, illustrating the use of timing functions and CSS styling within console output.
JavaScriptconsole.logfrontend
0 likes · 1 min read


Aotu LabOct 13, 2017 · Frontend Development
This article shows how to create a global timer object that tracks setTimeout and setInterval IDs, provides batch clearing, adds pause and resume capabilities, and demonstrates framework‑agnostic implementations inspired by CreateJS and PIXI, with full code examples and GitHub references.
CreateJSJavaScriptpause resume
0 likes · 7 min read

An in‑depth look at a common interview puzzle that prints “0 1 2 3 3 3”, explaining how JavaScript’s asynchronous setTimeout, function scope, and closures interact, why the output occurs, and how to modify the code to achieve the expected 0‑1‑2 sequence.
ES5ES6JavaScript
0 likes · 5 min read

This article explains how setTimeout works in JavaScript, covering its two parameters, the unique timer ID, the event‑queue execution after the call stack clears, and how closures can be used to preserve loop indices for correct output.
JavaScriptclosureevent-loop
0 likes · 5 min read

An in‑depth investigation compares requestAnimationFrame and setTimeout for web animations, revealing how the former syncs with browser repaint cycles, why it outperforms setTimeout, the limits of manually adjusting frame rates, compatibility issues across browsers and platforms, and practical fallback implementations.
Webanimationfrontend
0 likes · 9 min read

This article explains how JavaScript’s execution stack, heap, event loop, and setTimeout work together, illustrating their behavior with visual diagrams and examples that reveal common pitfalls such as blocking code and minimum timer delays.
JavaScriptTimersevent-loop
0 likes · 8 min read

Learn how JavaScript’s setTimeout and setInterval functions work, see practical code examples, understand their timing inaccuracies and common pitfalls, and discover how recursive setTimeout can provide more reliable scheduling by avoiding overlapping executions.
JavaScriptTimersasynchronous
0 likes · 4 min read

This article explains JavaScript's single‑threaded runtime, demystifies setTimeout's true behavior, discusses timer precision across browsers, and showcases practical patterns such as recursive timeouts, event throttling, GIF replay in IE, and delayed blur handling.
JavaScriptasynchronousevent-loop
0 likes · 12 min read

This article explains why the value of JavaScript’s this can be confusing, demonstrates typical mistakes with inline events, setTimeout/setInterval, DOM event handlers, and call/apply, and provides practical solutions such as using anonymous functions to control the binding correctly.
JavaScriptcall applyevent handling
0 likes · 4 min read

setTimeout schedules code to run after a delay by handing the callback to the browser’s Web APIs, which later places it in the task queue; once the call stack is empty, the event loop processes the queued callback, illustrating the asynchronous execution flow in JavaScript.
JavaScriptasynchronousevent-loop
0 likes · 3 min read
