The Rendering Phase
You'll learn how browser rendering fits into the event loop and when visual updates actually happen.
What Is the Rendering Phase?
The rendering phase is a special step in the event loop where the browser updates the screen. It doesn't happen after every task or microtask—the browser intelligently schedules it, typically trying to achieve 60 frames per second (about every 16 milliseconds).
Here's the crucial timing: after all microtasks are complete, but before the next task queue item runs, the browser gets a chance to render.
The Event Loop Order (Complete Picture)
- Execute one task from the task queue (like a
setTimeoutcallback) - Run all microtasks (promises,
queueMicrotask) - Rendering opportunity (browser decides if it's time to paint)
- Repeat from step 1
The browser doesn't render on every loop cycle. It checks if approximately 16ms have passed since the last frame and if there are visual changes to paint. If so, it updates the DOM, recalculates styles, performs layout, and paints pixels to the screen.
Why This Matters
If microtasks keep queuing more microtasks (microtask starvation), the rendering phase never gets reached—your UI freezes. Similarly, long-running synchronous code blocks rendering because the call stack never empties.
This is why breaking heavy work into chunks with setTimeout (tasks) allows the browser to render between chunks, keeping the UI responsive.
Key Takeaway: The rendering phase occurs between microtasks and the next task, giving the browser a chance to update the screen approximately 60 times per second if needed.