Browser rendering is not triggered by DOM mutations but is gated by JavaScript's scheduling boundaries. The browser will not render while a macrotask is running or while microtasks are draining — it only gets a chance to render after the current macrotask completes and the microtask queue is empty. Three practical experiments demonstrate this: multiple DOM updates in one macrotask show only the final state, microtask-based updates also delay rendering, and only a setTimeout (which creates a new task boundary) allows an intermediate state to be painted. This constraint ensures the browser always renders stable, consistent DOM states. The article teases requestAnimationFrame as the proper tool for scheduling work aligned with the browser's render cycle.

5m read timeFrom code.likeagirl.io
Post cover image
Table of contents
Rendering Is a Browser DecisionThe Rendering MisconceptionRunning the ExperimentsGet Marsha Teo ’s stories in your inboxTest 1: DOM Updates Inside One MacrotaskTest 2: Microtasks Also Delay RenderingTest 3: Breaking Into a New Task Allows PaintWhy Rendering WaitsThe Correct Mental ModelWhat This Prepares Us For Next

Sort: