What Is the CSS will-change
Property?
If you've ever experienced flickering or jittery visuals during certain CSS operations—especially transitions or animations—you’re not alone.
The will-change
property in CSS acts as a hint to the browser, indicating which aspects of an element are likely to change in the near future.
By providing this hint, the browser can prepare and optimize the necessary rendering resources in advance. This allows it to handle style changes and visual updates more efficiently when they actually occur. As a result, the page can appear smoother and more stable, minimizing flickers or other rendering glitches. Using will-change effectively can help improve the visual performance of your website.
Understanding Flickering, Jitter, and Their Connection to CPU, GPU, and Hardware Acceleration in CSS
CSS transitions and animations can sometimes cause visual issues such as flickering or jittering. These effects are often related to how the browser utilizes your system’s CPU, GPU, and hardware acceleration.
Let’s take a closer look at what these terms mean and how they impact rendering performance.
What Are Flickering and Jitter in CSS?
Flickering and jitter refer to sudden, unintended visual disruptions that occur during style transitions or animations. Instead of smooth motion, the browser may display unstable or choppy behavior—leading to a poor visual experience for users.
CPU(Central Processing Unit)
The CPU handles style calculations, layout processing, and animation frame updates during CSS operations.
When the CPU is overused or poorly optimized, visual artifacts like flickering or jitter can occur, especially during complex rendering tasks.
GPU (Graphics Processing Unit)
The GPU is specialized for handling graphics-related operations. It supports rendering tasks like transforms and animations more efficiently through parallel processing. A powerful GPU can help deliver smooth transitions and rich visual effects. But if the GPU is underpowered or overburdened, it may contribute to flickering or lag during animations.
Hardware Acceleration
Hardware acceleration—often referred to as GPU acceleration—enables the browser to offload rendering tasks to the GPU. By doing so, the CPU is freed up for other processing tasks, while the GPU manages graphical operations, resulting in faster rendering and smoother user interactions. When hardware acceleration is disabled or misconfigured, rendering performance can suffer, potentially causing flickering or jittering effects.
Why Not All CSS Properties Are GPU-Accelerated
Some browsers don’t automatically apply GPU acceleration to every CSS animation, transform, or transition. In those cases, the rendering is handled by the browser’s software engine, which relies primarily on the CPU. However, certain CSS properties are more GPU-friendly and benefit significantly from hardware acceleration.
Common GPU-Accelerated CSS Properties
opacity
The opacity
property is one of the most GPU-optimized styles.
When you apply a CSS transition or animation to opacity
, the browser often promotes the element to its own GPU layer. This allows the GPU to handle the visual update directly, improving performance and reducing visual glitches.
3D opacity
3D transforms are another commonly hardware-accelerated CSS feature.
Properties like transform: rotate3d()
or translateZ()
are well-suited to GPU processing, enabling smooth manipulation of element position, rotation, and scale in 3D space.
They also help create depth and realism in modern UI designs while delivering high performance.
Summary
In summary, CPU, GPU, and hardware acceleration all influence the visual stability of CSS-based interactions.
While some CSS properties naturally benefit from GPU acceleration, others may not—depending on the browser and device.
As a developer, understanding which properties trigger hardware acceleration allows you to optimize your styles for better rendering performance and smoother animations.
will-change
Property
The will-change
property provides a rendering hint to the user agent (the browser), indicating which changes a developer expects to occur on an element.
This allows the user agent to perform necessary optimizations in advance to ensure smooth rendering. As a result, developers can avoid jank—unwanted delays or stuttering—when modifying or animating the element.
Each browser handles the information provided by the will-change
property differently. Even within the same browser, the way this hint is used may vary over time.
For example, when you specify will-change: transform
, the browser may promote the element to its own GPU layer. However, declaring this for too many elements can lead to GPU memory shortages, causing performance issues. Because of this, browsers may limit or avoid this behavior.
In short, the will-change
property informs the browser about upcoming changes on an element. Each browser uses this hint in various ways to optimize rendering performance.
Formal syntax
selector {
will-change: /* value */
}
Formal definition
Initial value | auto |
---|---|
Applies to | all elements |
Inherited | no |
Syntax
/* Keyword values */
will-change: auto;
will-change: transform;
will-change: contents;
will-change: opacity;
will-change: scroll-position;
will-change: left, bottom;
/* Global values */
will-change: inherit;
will-change: initial;
will-change: revert;
will-change: revert-layer;
will-change: unset;
Values
auto |
The browser automatically decides which optimizations to apply for upcoming changes. |
---|---|
scroll-position |
Hints that the element’s scroll position may change, allowing the browser to optimize accordingly. |
contents |
Indicates that the contents of the element may change, prompting the browser to optimize rendering in advance. |
opacity |
Optimizes for upcoming changes to the element’s transparency. |
transform |
Optimizes for CSS transform changes, such as scaling, rotating, or translating. |
perspective |
Optimizes for changes to the perspective property, often used in 3D transforms. |
left/top/right/bottom |
Optimizes for upcoming positional changes using the specified directional property. |
filter |
Optimizes for changes to CSS filters like blur, brightness, or contrast. |
color/background-color |
ptimizes for changes to the element’s color or background color. |
all |
Suggests that all aspects of the element may change, so the browser can apply broad optimizations. |
The table above lists some common examples of will-change
values and describes what kind of changes each value is intended to optimize.
Actual support and behavior may vary depending on the browser and environment, so developers should choose the most appropriate value for each use case to take full advantage of hardware acceleration.
Browser compatibility
Attribute |
Desktop Chrome
|
DesktopDesktop Edge
|
Desktop Firefox
|
Safari
|
---|---|---|---|---|
will-change
|
36 | 79 | 36 | 9.1 |
Specifications
Specification | |
---|---|
will-change
|
CSS Will Change Module Level 1 #will-change |
Guidelines for Using the will-change
Property
Once you understand how the will-change
property works, you might be tempted to think, "Let’s just let the browser optimize everything!" It sounds reasonable—after all, wouldn't it be great if every potential change were already optimized and ready to go?
While will-change
is a powerful and effective tool, it's not unlike other forms of power: it comes with responsibility. Misusing this property can lead to performance degradation, and in some cases, may even cause your page to crash.
As with any performance-related hint, will-change
can have side effects that aren’t immediately obvious, which can make it tricky to use correctly. Here are a few important considerations to keep in mind. These will help you get the most out of this feature—without falling into the common traps that can hurt performance.
Don't Overuse It
will-change
is designed to help browsers optimize rendering for specific elements. But applying it too broadly—especially to many elements at once—can backfire. Instead of improving performance, it can significantly increase memory usage and reduce overall responsiveness.
Use will-change
only on elements where optimizations are truly needed. This selective use helps the browser allocate resources more efficiently.
Avoid Unnecessary Optimizations
When you use will-change
, you’re telling the browser to prepare for changes before they happen. But if those changes never occur, the browser may still carry out unnecessary pre-optimizations. This wastes valuable resources.
To avoid this, apply will-change
only to elements that are expected to change in the near future—not just any element that might change eventually.
Give the Browser Enough Time
There's a reason the property is called will-change
—it’s meant to signal that a change is going to happen, not that it’s happening right now. When you use this property, you’re requesting specific optimizations from the browser ahead of time. But in order to apply those optimizations effectively, the browser needs some lead time.
If you apply will-change
and immediately trigger the change, the browser may not have time to act on the hint—rendering it ineffective. Ideally, set will-change
slightly in advance (e.g., just before a user interaction or animation begins), then remove it once the change is complete.
Example: When will-change
Has No Effect
.box {
width: 100px;
height: 100px;
background-color: red;
transition: transform 0.3s;
}
.box:hover {
will-change: transform; /* Ineffective use */
transform: scale(1.2);
}
In this example, the will-change
property is applied at the same moment the transformation begins—on :hover
.
However, the browser needs some lead time to apply any meaningful optimizations based on will-change
.
Since the transformation is triggered immediately when the element is hovered, the browser doesn’t have enough time to act on the hint. As a result, the will-change
property has little to no effect, defeating its intended purpose.
To be effective, will-change
should be set before the change is expected to occur—ideally a short time in advance, such as during idle time or just before user interaction begins.
Example: When will-change
Works as Intended
.box {
width: 100px;
height: 100px;
background-color: red;
transition: transform 0.3s;
will-change: transform;
}
.box.optimized {
transform: scale(1.2);
}
<div class="box"></div>
// Add the optimization class after the page has loaded
window.addEventListener('load', () => {
const box = document.querySelector('.box');
box.classList.add('optimized');
});
In this example, the will-change
property is set on the .box
element from the beginning—before any transformation occurs. Then, after the page has loaded, the .optimized
class is added, triggering the transform
.
Because the browser has had time to prepare in advance, the will-change
hint is effective, and the resulting transition is more likely to benefit from performance optimizations like GPU acceleration or compositing.
To take full advantage of the will-change
property, you should always apply it before a change is expected, not at the exact moment the change occurs. Setting it ahead of time allows the browser to allocate resources and prepare optimizations.
Avoid scenarios where the hint and the change happen simultaneously—doing so will prevent the browser from making use of the optimization.
Remember to Remove will-change
After Use
The will-change
property can consume a significant amount of system resources.
Browsers typically try to clean up such optimizations and revert elements back to their normal rendering paths as soon as possible. To avoid unnecessary overhead, it’s important to remove the will-change
hint once the change is no longer needed.
If you leave will-change
applied indefinitely—especially on multiple elements—it can degrade overall performance by holding onto expensive optimizations like GPU layers or memory allocations.
By explicitly removing the property after the effect has completed, you help the browser free up resources and keep your application running efficiently.
will-change
// Get the element to animate on interaction
const el = document.getElementById('element');
// Set the will-change hint on mouseenter
el.addEventListener('mouseenter', hintBrowser);
// Remove the hint once the animation ends
el.addEventListener('animationend', removeHint);
function hintBrowser() {
// Tell the browser to prepare for transform and opacity changes
this.style.willChange = 'transform, opacity';
}
function removeHint() {
// Revert to default to release resources
this.style.willChange = 'auto';
}
In this example, we provide a hint to the browser just before an animation begins—specifically on mouseenter
.
Once the animation completes (captured via the animationend
event), we reset the will-change
property back to its default value of 'auto'
.
This pattern ensures that the optimization is applied only when necessary, which improves performance while minimizing memory and GPU usage.
Conclusion
The will-change
property allows developers to inform the browser of upcoming changes to specific elements.
By doing so, the browser can prepare in advance and apply optimizations proactively—leading to smoother performance and a better user experience.
When used properly, will-change
can significantly improve the rendering efficiency of your web application.
Key Benefits of will-change
Improved Rendering Performance
By signaling which properties are likely to change, will-change
gives the browser a head start.
This allows it to pre-allocate resources or trigger GPU acceleration early—resulting in smoother visual updates and faster frame rendering.
Optimized Animations
The property is especially effective when used with CSS animations involving transform
or opacity
.
These types of changes often benefit from GPU-based compositing, and will-change
helps ensure those optimizations are applied in time.
Use With Care
While will-change
is a powerful tool, it must be used responsibly:
- Apply it selectively – Only use
will-change
on elements where changes are certain to occur. Applying it too broadly can increase memory usage and reduce overall performance. - Use it ahead of time – Set the property before the change occurs to give the browser time to act.
- Clean up after use – Once the optimization is no longer needed, remove the
will-change
hint to free up resources.
By following these best practices, will-change
can become a valuable part of your performance optimization toolkit—helping to deliver faster, smoother, and more responsive web experiences.