liveBook · Manning

Browser rendering pipeline

As explained in Secrets of the JavaScript Ninja, Second Edition

The browser process of producing or updating a web page’s visual presentation from its document and styles.

A busy JavaScript task can leave a page looking frozen: the browser suspends visual updates while JavaScript runs. Rendering can happen between tasks, but not before queued microtasks run. section 13.1.2 section 13.2.2

Figure 13.9. A page can be re-rendered between two macrotasks (mainline JavaScript execution and first click handler), while it can’t be rendered before a microtask is executed (before the promise handler).

This timing diagram shows where a page may be re-rendered relative to macrotasks and a promise microtask. section 13.1.2

For expensive work, such as building thousands of DOM rows, split processing into chunks and schedule later chunks with a timer. This gives the event loop opportunities to handle other work instead of letting one long task monopolize execution. section 13.2.2

How Secrets of the JavaScript Ninja, Second Edition covers it

How deep it goes
Explains rendering checkpoints between tasks and after microtasks, but does not detail layout or paint internals.
Examples
Uses a resolved-promise click handler and timer-chunked creation of 20,000 table rows.
What you can do after
Apply timer-based chunking to expensive JavaScript work to keep the interface responsive.
How it connects
Connects rendering with the event loop, macrotasks, microtasks, promises, timers, and DOM work.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Secrets of the JavaScript Ninja, Second Edition. The section links point to the parts of the book it draws on.