will-change
The will-change CSS property enables optimizing animations by providing a rendering hint to a browser about how an element is expected to change.
Browser support
| Feature | Desktop | Mobile | ||||
|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Safari | Chrome Android | Safari iOS | |
| 36 | 79 | 36 | 9.1 | 36 | 9.3 | |
auto | 36 | 79 | 36 | 9.1 | 36 | 9.3 |
contents | 36 | 79 | 36 | 9.1 | 36 | 9.3 |
scroll-position | 36 | 79 | 36 | 9.1 | 36 | 9.3 |
1+Supported (version) Not supported ※Has note Sub-feature descriptions sourced from MDN Web Docs (CC BY-SA 2.5)
Syntax
CSS
/* Optimize hover animations */
.card:hover {
will-change: transform;
}
.card:active {
transform: scale(0.98);
}
/* Apply and remove dynamically via JS */
.animating {
will-change: transform, opacity;
} Live demo
Use cases
-
Using will-change
The will-change CSS property enables optimizing animations by providing a rendering hint to a browser about how an element is expected to change.
Cautions
- May not be supported in older browsers.
Accessibility
- Make sure visual changes are conveyed appropriately to assistive technology.