call(back)

Repaint or Reflow?

What is the difference between a repaint and a reflow?

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

Hints

Hint 1

Answer by naming which rendering steps each kind of change re-runs, then say what forces layout early.

Solution

Show the approach

Answer

A geometry change (size, position, font, adding nodes) re-runs steps 4 to 6. A visual-only change, such as a color, re-runs 5 and 6. transform and opacity re-run only step 6. Reading offsetHeight after a write forces layout immediately, and alternating reads and writes in a loop is layout thrashing: batch the reads, then the writes.

Asked at