"What happens between HTML arriving and pixels appearing?" โ the question that reveals whether performance advice is memorized or understood.
The pipeline
- Parse HTML โ DOM (pausing at sync scripts!)
- Parse CSS โ CSSOM โ CSS is render-blocking: no pixels until it's ready
- DOM + CSSOM โ Render tree (visible elements with computed styles)
- Layout (reflow): calculate every box's position and size
- Paint: fill in pixels โ text, colors, shadows
- Composite: layers assembled on the GPU
Why this explains all the advice
deferon scripts โ parsing never pauses (step 1)- Minimal critical CSS โ step 2 unblocks faster โ faster first paint
- Changing
widthโ relayout + repaint + composite (expensive, cascades to children) - Changing
colorโ repaint + composite (medium) - Changing
transform/opacityโ composite ONLY โ GPU moves an existing layer. That's the whole "only animate transform" rule, derived instead of memorized
Seeing it live
DevTools โ Performance โ record a page load: parse, layout (purple), paint (green) laid out on a timeline. Rendering tab โ "Paint flashing" highlights repaints as you interact โ watching a janky animation light the whole screen green is the lesson that sticks.
โ All Articles