Skip to the page

How the browser draws the page · mid

Style, layout, paint and composite

Changing layout properties (width, top) re-runs layout and paint; changing paint-only properties (color) re-runs paint; changing transform or opacity can skip both and only composite, which is why smooth animations use them.

The notes

What you must know

  • Reflow (layout) = recompute geometry; repaint = redraw pixels; composite = combine layers on the GPU.
  • Layout triggers: width, height, margin, top/left, font-size, adding nodes. Paint only: color, background, box-shadow.
  • Composite only: transform and opacity (on a promoted layer). will-change: transform hints a layer; overusing it costs memory.
  • contain and content-visibility: auto can limit how much layout work a change causes.

The red pen

Common traps: mistake → fix

  • Mistake: "reflow and repaint are the same"

    Fix: layout is the expensive geometry step; repaint can happen without it.

  • Mistake: "animating left is as smooth as transform"

    Fix: left triggers layout every frame.

Easy to hard

Questions interviewers ask, easy to hard

  1. Reflow vs repaint?
  2. Why animate transform instead of top?
  3. What is a compositor layer?

Your first interview is free

Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.

Start your free interview