Browser JavaScript Timer Throttling: Why setTimeout(0) Actually Delays 4ms
By
vidyesh
Sesame, salt, and substance. A flagship bake.
Summary
This article explains how browsers implement a 4ms minimum delay for JavaScript setTimeout(0) calls, rather than executing them immediately. The author, who worked on the Microsoft Edge team, reveals this is a deliberate browser design choice to prevent websites from abusing timers and draining user battery life or blocking interactivity through excessive setTimeout spamming.
Key quotes
· 3 pulledsetTimeout(0) is not really setTimeout(0). Instead, it could run 4 milliseconds later
browsers did this to avoid "abuse". I.e. there are a lot of websites out there that spam setTimeout
to avoid draining the user's battery or blocking interactivity, browsers set a special "clamped" minimum of 4ms
You might also wanna read
WebSparks: An AI-Powered Tool for Building Web Applications Without Extensive Coding
WebSparks is an AI-powered software engineer that transforms ideas into fully functional web applications without requiring extensive coding
innovirtuoso.com·18h agoJoost de Valk publishes open Website Specification: 128 rules for modern, future-proof websites
Joost de Valk, creator of Yoast SEO, published the Website Specification (specification.website) — an open, platform-agnostic reference docu
ZX Spectrum BASIC interpreter rebuilt from scratch to run natively in web browsers
A developer has rebuilt the ZX Spectrum's BASIC interpreter from scratch to run in a web browser, without emulating the original Z80 hardwar
How to Set Up an Apache Reverse Proxy for an Ecommerce Website
This article provides a comprehensive, start-to-finish guide on setting up an Apache reverse proxy specifically for ecommerce websites. It c
blog.radwebhosting.com·2d agoImplementing live text search in React with Firestore Enterprise's built-in search pipeline
Firebase's Firestore Enterprise edition now includes built-in text search support. This article demonstrates how to implement live text sear
firebase.blog·2d agowterm: A DOM-based Web Terminal Emulator Powered by Zig and WebAssembly
wterm is a web-based terminal emulator that renders directly to the DOM, providing native text selection, copy/paste, find functionality, an
