Tagged articles
25 articles
Page 1 of 1
JavaScript
JavaScript
Nov 29, 2025 · Frontend Development

Why setTimeout Falls Short and How requestIdleCallback Keeps Your UI Smooth

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
Why setTimeout Falls Short and How requestIdleCallback Keeps Your UI Smooth
JavaScript
JavaScript
Jul 11, 2025 · Frontend Development

Make JavaScript Polling Smarter: From setInterval to Adaptive Strategies

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.

JavaScriptPage Visibility APIPolling
0 likes · 6 min read
Make JavaScript Polling Smarter: From setInterval to Adaptive Strategies
JavaScript
JavaScript
Jun 27, 2025 · Frontend Development

How setTimeout(fn, 0) Unblocks the Main Thread and Boosts UI Responsiveness

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.

AsynchronousJavaScriptevent loop
0 likes · 10 min read
How setTimeout(fn, 0) Unblocks the Main Thread and Boosts UI Responsiveness
Rare Earth Juejin Tech Community
Rare Earth Juejin Tech Community
May 12, 2025 · Frontend Development

Understanding Browser Rendering, Event Loop, and Techniques to Avoid Page Jank When Adding Massive DOM Elements

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.

BrowserDOMJavaScript
0 likes · 16 min read
Understanding Browser Rendering, Event Loop, and Techniques to Avoid Page Jank When Adding Massive DOM Elements
JavaScript
JavaScript
Apr 14, 2025 · Frontend Development

7 Better Alternatives to setTimeout for Reliable JavaScript Timing

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
7 Better Alternatives to setTimeout for Reliable JavaScript Timing
Rare Earth Juejin Tech Community
Rare Earth Juejin Tech Community
Dec 12, 2024 · Frontend Development

Understanding JavaScript setTimeout and setInterval and Implementing setInterval Using setTimeout

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.

JavaScriptfrontendsetInterval
0 likes · 12 min read
Understanding JavaScript setTimeout and setInterval and Implementing setInterval Using setTimeout
58 Tech
58 Tech
May 26, 2022 · Frontend Development

Advanced Timer Techniques in 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
Advanced Timer Techniques in Frontend Development
Fulu Network R&D Team
Fulu Network R&D Team
Aug 10, 2021 · Frontend Development

Implementing Zero-Delay Timers in JavaScript: Alternatives to setTimeout

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
Implementing Zero-Delay Timers in JavaScript: Alternatives to setTimeout
Laravel Tech Community
Laravel Tech Community
Aug 25, 2020 · Frontend Development

Why You Should Avoid Using setInterval in JavaScript

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
Why You Should Avoid Using setInterval in JavaScript
MaoDou Frontend Team
MaoDou Frontend Team
Jun 18, 2019 · Frontend Development

How a Joke Sorting Algorithm Reveals JavaScript’s Event Loop Mechanics

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.

AsynchronousJavaScriptSorting Algorithm
0 likes · 6 min read
How a Joke Sorting Algorithm Reveals JavaScript’s Event Loop Mechanics
JavaScript
JavaScript
Jan 1, 2018 · Frontend Development

Schedule a Two‑Hour Delayed Console Message with setTimeout

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
Schedule a Two‑Hour Delayed Console Message with setTimeout
Aotu Lab
Aotu Lab
Oct 13, 2017 · Frontend Development

Extend setTimeout/setInterval with Pause, Resume, and Batch Management

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
Extend setTimeout/setInterval with Pause, Resume, and Batch Management
Qudian (formerly Qufenqi) Technology Team
Qudian (formerly Qufenqi) Technology Team
Jan 17, 2017 · Frontend Development

Why requestAnimationFrame Beats setTimeout for Smooth Animations – A Deep Dive

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
Why requestAnimationFrame Beats setTimeout for Smooth Animations – A Deep Dive
JavaScript
JavaScript
Oct 5, 2016 · Frontend Development

Mastering JavaScript Timers: setTimeout, setInterval, and Their Pitfalls

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.

AsynchronousJavaScriptTimers
0 likes · 4 min read
Mastering JavaScript Timers: setTimeout, setInterval, and Their Pitfalls