Layout thrashing

Also called forced synchronous layout or forced reflow

A slowdown caused by code that alternates style changes with size reads, forcing the browser to recalculate layout many times in one frame.

What is Layout thrashing?

Normally the browser collects your style changes and recalculates layout once per frame. Reading a layout value such as offsetHeight, offsetWidth, or getBoundingClientRect() right after a change forces it to lay out the page immediately so the answer is correct. Do that in a loop, changing then measuring element after element, and the browser redoes layout on every pass.

It often hides in code that sizes a list of elements, matches card heights, or measures things on every scroll event. In the Chrome DevTools Performance panel it shows up as a run of purple Layout blocks with a forced reflow warning.

The fix is to batch: read every measurement first, then make every change. ResizeObserver reports sizes without forcing extra layouts, and CSS Grid or Flexbox can often replace the measuring entirely. For motion, animating width, height, top, or left makes the browser lay out again on every frame, while transform and opacity usually skip layout.

Often confused with

Jank
Jank is the stutter you see. Layout thrashing is one common cause of it.
All terms

Jank

Visible stutter in an animation or scroll, caused when the browser misses frames because it cannot finish its work in time.

GPU acceleration

A browser technique where the graphics chip moves, fades, or scales an element on its own layer instead of redrawing the page every frame.

Frame rate (FPS)

The number of frames a screen draws each second; around 60 fps, motion looks smooth, and at lower rates it starts to look choppy.

Debounce

A technique that waits for a short pause in typing or other repeated events, then runs the work once instead of on every keystroke.