The pixel pipeline in one screen
The one-page summary of the lesson Parse, style, layout, paint, composite. It states the answers, so if you want them to stick, play the lesson first: it makes you predict before it explains.
The points
- Each frame: style (rules) → layout (boxes) → paint (pixels, onto layers) → composite (layers into the frame).
- A change re-runs the stages from the first one it touches.
- Geometry (left, top, width, height): layout, paint, composite.
- Paint-only (color, background, box-shadow): skips layout.
- transform and opacity on their own layer: composite only.
- The compositor runs on its own thread, apart from your JavaScript.
- 60 fps ≈ 16.7 ms per frame for all of it.
What catches people out
- transform skips paint only if the element is on its own layer.
- Setting a style from JS still runs style recalc each frame.
- Every layer costs memory: use will-change sparingly.
The wrong idea, and the right one
Often believed: Any CSS change costs the same: the browser just redraws the page.
What really happens: Each frame can run style, layout, paint and composite. A change re-runs the stages from the first one it affects: left and width start at layout, colours at paint, and transform or opacity on their own layer go straight to composite.
Step by step
- Symptom. A smooth animation on a fast laptop can stutter on a phone.
- Style. Style: match rules to elements, compute final styles.
- Layout. Layout: the size and position of every box.
- Paint. Paint: fill in the pixels, layer by layer.
- Composite. Composite: stack the layers into one frame, on the compositor thread.
- Measured. transform skips layout and paint; left runs them every frame.
- Break it: colour. Colour changes skip layout but not paint.
- Agent bug. Animate transform and opacity, not left, top, width or height.
- Recap. Style → layout → paint → composite.