When to Use CSS will-change and the Effects of Overusing It
CSS will-change is a hint that tells the browser in advance which properties are about to change. The basic usage is to add it shortly before an element starts moving and remove it once the movement ends. If you add it too much, the Chromium I tested created a composited layer for each element, and the drawing memory grew with the number of elements. Also, an element with will-change: transform or opacity changes how z-index stacking works even when the value is still the initial one. With transform, the containing block for position: fixed elements also changes.
The test environment was Ubuntu 24.04, Node.js 22.23.4, Playwright 1.63.0, and headless Chromium 153. I checked the number of composited layers and the reason each one was created using the LayerTree domain of the Chrome DevTools Protocol. The drawing memory is the value of cc/tile_memory (the memory for tiles that hold the rendered result of the page) in the memory dump from Chromium's memory-infra. I did not test Firefox, Safari, real smartphones, or regular Chrome with GPU use. I also did not measure animation smoothness (frame rate).
will-change is a notice that something is about to change
The CSS specification defines will-change as a rendering hint that tells the browser what kind of change an element is going to undergo. The browser can then prepare in advance so that the change is drawn smoothly. The value is a comma-separated list of property names, such as transform or opacity.
.menu {
will-change: transform;
}
The introduction of the specification explains that preparing things such as moving an element to a separate layer takes effort, and that it can visibly delay the start of an animation. will-change is meant for doing that preparation before the change begins.
When I inspected an element with will-change: transform in the test Chromium, the element was a separate composited layer. The reason for the layer was WillChangeTransform.
On the other hand, even without will-change, an element became a composited layer while transform was being animated by a transition. The reason was ActiveTransformAnimation, and the layer disappeared when the movement ended. MDN also says that the properties targeted by an animation are treated as if they were already included in will-change. will-change is useful when you want that preparation done before the movement starts.
When to use it
When you know shortly before something moves
The most basic usage is to add will-change from a script as soon as you know a change is likely, and remove it when the change ends. For a menu that opens on click, you can add it when the mouse enters the element.
const menu = document.getElementById("menu");
menu.addEventListener("mouseenter", () => {
menu.style.willChange = "transform";
});
menu.addEventListener("transitionend", () => {
menu.style.willChange = "auto";
});
menu.addEventListener("click", () => {
menu.classList.toggle("open");
});
#menu {
transition: transform 1s linear;
}
#menu.open {
transform: translateX(300px);
}
I checked the composited layers of this element at each point in time, with the following results.
| Point in time | Composited layer (reason) |
|---|---|
| Right after the page opened | None |
| After the mouse entered | Yes (WillChangeTransform) |
| 0.25 seconds after clicking (while moving) | Yes (ActiveTransformAnimation and WillChangeTransform) |
| After the movement ended | None (will-change had returned to auto) |
The layer was prepared when the mouse entered, and after the movement ended, transitionend removed will-change and the layer was gone.
The specification's explanation of when to apply will-change says that if you apply it just before a change, the browser may not have time to prepare, so it has little effect. For an element that changes on click, applying it on hover gives the browser time: people react relatively slowly, so the optimization can usually have at least 200 milliseconds. For an element that changes on hover, the specification also gives a CSS example that applies it on hovering over the parent element.
.element {
transition: opacity 0.2s;
opacity: 1;
}
.container:hover > .element {
will-change: opacity;
}
.element:hover {
opacity: 0.3;
}
The MDN page for will-change also has an example script that adds it on mouseenter and removes it at the end of the animation. However, in the MDN text I retrieved on November 9, 2026 (both the Japanese and English versions), the removal side was written as addEventListener("animationEnd", ...) with a capital E. Event names are case-sensitive. In the test environment, when I registered a function under both animationEnd and animationend on an element with a 0.2-second CSS animation, only animationend was called (animationEnd was called 0 times, and animationend 1 time). If you copy the example as written, will-change will not be removed.
A small number of UI parts, and elements that keep moving
The specification's explanation of writing it in a stylesheet gives two cases where it is acceptable to write it directly in a stylesheet. One is a small number of UI parts that must react immediately to user actions, such as a sidebar that slides open. The other is elements that are almost always changing, such as elements that keep moving in response to mouse movement.
MDN also says that in cases such as a slide show that switches pages with keyboard input, writing it in the stylesheet may be appropriate. It then warns that the browser may keep memory it no longer needs, so care is required.
When a performance problem is actually happening
MDN warns that will-change should be used as a last resort for performance problems that already exist. It is not something to add as a precaution before a problem occurs. If the page is running fast enough, you do not need to add it.
Effects of overusing it
Composited layers and memory grow
In the test environment, I made a page with 30 slides of 720×520px stacked at the same position. I changed how many of them had will-change: transform and measured Chromium's tile memory (cc/tile_memory).

Without will-change, all 30 slides were drawn together as one screen, and the tile memory was 2.3 MB. As the number of elements with will-change increased, so did the number of layers. When all 30 slides had it, there were 30 layers and the memory rose to 67.5 MB. I measured the same page twice, and both times the value was the same.
When only one slide had it, two slide-sized layers were created. One was the layer of the slide with will-change (the reason was WillChangeTransform). The other was a layer whose reason was shown as Overlap. Parts of other slides that overlapped the slide with will-change also became separate layers.
When will-change: opacity was applied to all 30 slides, there were also 30 layers and the memory was 67.5 MB, the same as with transform.
The specification's explanation of overuse gives an example of applying it to every element, such as * { will-change: transform, opacity; }, as a bad practice. It says that browsers already optimize as much as they can, so adding this does not help, that strong optimizations use many resources, and that overusing it in this way can make pages slow or even crash. The specification's note also says that browsers which move elements with will-change: transform into GPU layers may decline to do so when too many elements are specified, so that they do not exhaust GPU memory. The growth I measured here is one example from Chromium 153.
According to the specification's explanation of elements after a change has ended, browsers normally remove optimizations as early as possible and return to the normal state. will-change overrides that and keeps the optimization in place for longer. This is why you should remove it after the movement ends, as in the script in the previous section.
The stacking order of z-index changes
The specification states that if you write a property in will-change that creates a stacking context with a non-initial value, the element also creates a stacking context. As the MDN page on stacking context explains, opacity less than 1 and transform other than none create a stacking context. So applying will-change: opacity or will-change: transform creates a stacking context even when the value is still the initial one.
In the test environment, I placed a child with z-index: 10 inside a position: relative parent, and overlapped it with an element outside the parent that had z-index: 1.
<div id="parent" style="position: relative; will-change: opacity">
<div id="child" style="position: absolute; z-index: 10">…</div>
</div>
<div id="other" style="position: absolute; z-index: 1">…</div>
When the parent had no will-change, the child (z-index: 10) was visible on top where they overlapped. When the parent had will-change: opacity or will-change: transform, the element outside the parent (z-index: 1) appeared on top instead. An element inside a stacking context is stacked separately from outside elements, so the child's z-index: 10 can no longer be compared with the outside element. When the parent had will-change: top or the custom property will-change: --x, the child stayed on top.
Elements with position: fixed stop being fixed to the screen
The specification states that if you write a property in will-change that creates a containing block for position: fixed or position: absolute with a non-initial value, the element also creates a containing block. The CSS Transforms specification states that when transform is other than none, the element creates a containing block for absolutely and fixed-positioned descendants.
In the test environment, I applied will-change: transform to a main element that contained a position: fixed header, and scrolled the page by 300px.

Without will-change, the top edge of the header stayed at the top of the screen (0px) even after scrolling. With will-change: transform, the header was positioned relative to main, scrolled along with the body text, its top edge went to -300px, and it disappeared from the screen. In a separate simple page, will-change: filter made the header scroll away in the same way. With will-change: opacity, the header stayed fixed to the screen.
The same thing happened with absolute positioning. I placed a child with position: absolute; top: 0; left: 0 inside a parent without a position value (margin: 100px). Without will-change on the parent, the child was placed at the top-left of the page (0, 0). When the parent had will-change: transform, the child was placed at the top-left of the parent (100, 100). will-change: position gave the same result.
If you apply it to an element that wraps the whole page, the fixed header inside it stops being fixed to the screen, as in the test above. MDN also warns that applying it to a broad range, such as body, can actually make performance worse, and advises using it only on narrow, deeply nested elements where needed.
Layers can also come from names other than transform and opacity
The specification says that most properties have no effect when written in will-change, and that this is safe. For custom properties, it is decided that they must have no effect.
However, in the test Chromium, when I applied will-change: top to 30 slides with position: absolute, all 30 became layers, and the memory was 67.5 MB, the same as with transform. The reason was WillChangeOther. The specification's examples also include a case that writes will-change: left, top; for an element that moves around the screen. Even names other than transform and opacity can increase memory when overused.
Browser support
According to the compatibility data (@mdn/browser-compat-data 8.1.8), will-change is available from Chrome 36, Edge 79, Firefox 36, Safari 9.1, and Safari on iOS 9.3.





