CSS Portal

CSS will-change Property

If this site has been useful, we’d love your support! Consider buying us a coffee to keep things going strong!

Description

The will-change property is a performance hint that lets authors tell the browser which aspects of an element are likely to change soon so the rendering engine can prepare optimizations in advance. By advertising upcoming changes, the browser can make decisions such as promoting the element to its own compositing layer, precomputing intermediate states, or adjusting rasterization strategies to reduce frame drops and layout thrashing when the change actually happens. Crucially, it is only a hint — browsers retain freedom to ignore it if applying the hint would be more expensive than beneficial in a given context.

Using will-change affects the browser’s internal work pipeline (layout, painting, compositing, rasterization) rather than changing visual behavior directly. For example, elements that are composited can be animated more smoothly because the compositor can move pixels without forcing a full repaint on each frame; this is why it’s frequently used ahead of changes to properties like transform, opacity, or filter. However, those optimizations come with trade-offs: creating extra layers increases memory use and may increase the cost of certain operations (for example, when layers need to be rasterized at different resolutions), so indiscriminate or long-lived use of the hint can worsen overall performance rather than improve it.

Best practice is to use will-change sparingly and only for the brief period surrounding the change. Add the hint just before you trigger a transition or animation and remove it when the operation finishes; this limits the time the browser has to carry extra resource overhead. In many cases, structural techniques such as limiting repaint scope with the contain property or choosing properties that are naturally handled on the compositor can be preferable. Also consider pairing the hint with animation strategies (for example, using transition or animation that target compositable properties) so the browser can take advantage of hardware-accelerated compositing without unnecessary painting work.

Finally, remember that will-change is an optimization tool, not a fix for layout or scripting inefficiencies. Profiling and testing remain essential: measure frame rates and memory usage with and without the hint, and prefer design patterns that minimize forced synchronous layouts and costly paint operations in the first place.

Definition

Initial value
auto
Applies to
all elements
Inherited
no
Computed value
as specified
Animatable
yes
JavaScript syntax
object.style.willChange

Syntax

will-change: auto | <animatable-feature>

Values

  • autoThe browser will apply the optimizations it thinks are best.
  • <animatable-feature>The <animatable-feature> can be one of the following values:
    scroll-position - Indicates that the scroll position of the element is likely to change.
    contents - Indicates that the contents of the element are likely to change.

Example

<body>
<main class='wrapper'>
<h2>CSS will-change demo</h2>
<div class='card' tabindex='0' aria-label='Example card'>
<div class='card__content'>
<h3>Hover or focus me</h3>
<p>Hinting the browser with <code>will-change: transform, opacity</code></p>
</div>
</div>
<p class='note'>Tip: Interact with the card to see smoother animations when hints are used.</p>
</main>
</body>
/* Basic layout */
body {
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  margin: 0;
  background: linear-gradient(135deg, #f0f4ff, #ffffff);
  color: #0f172a;
}

/* Wrapper */
.wrapper {
  text-align: center;
  padding: 32px;
}

/* Card with will-change hint */
.card {
  width: 280px;
  margin: 24px auto;
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
  transition: transform 240ms cubic-bezier(.2, .8, .2, 1), opacity 200ms linear, box-shadow 240ms;
  will-change: transform, opacity;
  cursor: pointer;
  outline: none;
}

/* Content inside card */
.card__content {
  padding: 20px;
}

/* Hover and focus states trigger an animation */
.card:hover,
.card:focus {
  transform: translateY(-14px) scale(1.01);
  opacity: 0.98;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.12);
}

/* Small note */
.note {
  margin-top: 12px;
  font-size: 13px;
  color: #475569;
}

/* Inline code styling */
code {
  background: #f8fafc;
  padding: 2px 6px;
  border-radius: 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, 'Roboto Mono', monospace;
  font-size: 13px;
}

Browser Support

The following information will show you the current browser support for the CSS will-change property. Hover over a browser icon to see the version that first introduced support for this CSS property.

This property is supported by all modern browsers.
Desktop
Chrome
Edge
Firefox
Opera
Safari
Tablets & Mobile
Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-

Last updated by CSSPortal on: 1st January 2026

If this site has been useful, we’d love your support! Consider buying us a coffee to keep things going strong!