will-change

A CSS property that tells the browser an element is about to animate, so it can prepare, often by giving the element its own layer ahead of time.

will-change explained

Setting will-change: transform or will-change: opacity tells the browser which properties are about to change. It may respond by promoting the element to its own compositor layer before the animation starts, so the first frames do not pay for creating and painting that layer.

It is only a hint, and browsers are free to ignore it. Reach for it to fix a real problem, such as an animation that stutters on its first frames or an element that moves constantly, like a draggable card.

Every promoted layer keeps its own bitmap in memory, so putting will-change on many elements, or on *, can make a page slower and use up memory on low-end phones. Add it shortly before the motion, for example on hover or pointer down, and remove it when the animation ends.

It has side effects: will-change: transform creates a new stacking context and becomes the containing block for position: fixed children, which can change how z-index and fixed elements behave.

Often confused with

GPU acceleration
GPU acceleration is the browser compositing layers on the graphics chip. will-change only asks it to set up a layer early.
All terms

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.

Jank

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

Z-index

A CSS property that decides which element appears on top when elements overlap, with higher numbers sitting closer to the viewer.

Layout thrashing

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