will-change

will-change

The will-change property in CSS optimizes animations by letting the browser know which properties and elements are just about to be manipulated, potentially increasing the performance of that particular operation.

This property has four values:

  • auto: standard browser optimizations will be applied.
  • scroll-position: indicates that the element’s scroll position will be animated sometime in the near future so the browser will prepare for content which is not visible in the scroll window of an element.
  • contents: the contents of an element is expected to change so the browser will not cache this element’s content.
  • <custom-ident>: any user-defined property such as transform or opacity that we want will-change to be applied to.

We can inform the browser that a change is about to take place to the transform property like so:

.element {
  will-change: transform;
}

Or if we want to declare multiple values we can use a comma-separated list such as:

.element {
  will-change: transform, opacity;
}

It's important not to overuse the will-change property however since it might, in fact, cause the page to be less performant (note that there is not an all value for this property for a good reason). As a result, MDN recommends that the property be used as a last resort for existing performance issues rather than ones you anticipate could happen. And, when using it, it's recommended to toggle will-change just before an element or property changes and then toggle it off again shortly after the process is finished.

Other resources

Browser support

This browser support data is from Caniuse, which has more detail. A number indicates that browser supports the feature at that version and up.

Desktop

ChromeOperaFirefoxIEEdgeSafari
362436NoNo9.1

Mobile / Tablet

iOS SafariOpera MobileOpera MiniAndroidAndroid ChromeAndroid Firefox
9.346No677063
icon-anchoricon-closeicon-emailicon-linkicon-logo-staricon-menuicon-nav-guideicon-searchicon-staricon-tag