call(back)

How Does the Browser Turn HTML Into Pixels?

Walk through how the browser turns HTML into pixels.

Answer out loud in under a minute: a definition, one concrete example, and one pitfall or trade-off.

Hints

Hint 1

Learn the pipeline as six numbered steps, and say which of them scripts and CSS can block.

Solution

Show the approach

Answer

  1. Parse HTML into the DOM. A plain <script> pauses the parser; defer and async do not.
  2. Parse CSS into the CSSOM. CSS blocks rendering, and it also blocks any script that follows it.
  3. Build the render tree from the visible nodes and their computed styles. display: none nodes are left out.
  4. Layout, also called reflow: compute every box's size and position.
  5. Paint pixels into layers.
  6. Composite the layers on the GPU.

Asked at