Web Animation Performance: A 60fps Guide
Smooth web animation comes down to one choice: animate transform and opacity, and avoid properties that force layout or paint on every frame. On a 60Hz screen the browser has about 16.66 milliseconds per frame, and web.dev advises keeping your own work near 10 milliseconds of that. Layout-triggering properties such as width, top or margin rarely fit.
The rest of this page explains why, shows how to rebuild common effects (slide-ins, modals, list reorders, accordions) around cheap properties, and walks through measuring the result in Chrome DevTools instead of judging it by eye. It closes with the motion rules from WCAG 2.2, because an animation that runs at 60fps can still make some readers dizzy.
How the browser builds a frame
web.dev's rendering performance article describes five stages that can run for every frame: JavaScript, Style, Layout, Paint and Composite.
- JavaScript runs whatever code changes the page, including animation callbacks.
- Style works out which CSS rules now apply to which elements.
- Layout computes geometry: where each box sits and how big it is. A change to one element's size can move its siblings and its children, so the work spreads.
- Paint turns boxes into pixels: text, colors, borders, shadows, images. web.dev notes that paint covers both creating draw calls and rasterizing.
- Composite stacks the painted layers in the right order and sends the result to the screen.
Not every change runs all five stages. The same article lists three paths:
| What changed | Stages that run | Example properties named by web.dev |
|---|---|---|
| Geometry | Style, Layout, Paint, Composite | width, height, top, left |
| Appearance only | Style, Paint, Composite | background-image, color, box-shadow |
| Neither geometry nor paint | Style, Composite | transform, opacity |
The third row is the one to aim for. web.dev's animations guide puts it directly: where possible, restrict animations to opacity and transform, and avoid any property that triggers layout or paint unless it is absolutely necessary.
The frame budget at different refresh rates
web.dev says most devices refresh 60 times a second, which gives the browser 16.66 ms per frame, and that browser overhead leaves roughly 10 ms for your own work. Faster screens shrink the window. The figures below are plain division (1,000 ms divided by the refresh rate), shown so you can see how quickly the margin disappears:
| Refresh rate | Time per frame | Notes |
|---|---|---|
| 60 Hz | 16.67 ms | web.dev's working figure is 16.66 ms, with about 10 ms for your code |
| 90 Hz | 11.11 ms | A third less time than at 60 Hz |
| 120 Hz | 8.33 ms | Half the 60 Hz window |
| 144 Hz | 6.94 ms | Well under the 10 ms work target |
A layout-heavy animation that squeaks by at 60 Hz has no chance at 120 Hz. A compositor-only animation usually holds up at any of these rates because most of its per-frame work never touches the main thread's layout and paint stages.
Pick the property from the effect you want
Most visual effects that designers ask for have a cheap version. This table maps the request to the property to animate and the one to leave alone.
| Effect you want | Animate this | Instead of this | Why |
|---|---|---|---|
| Slide a drawer in from the side | transform: translateX() | left, right, margin-left | Position changes force layout every frame |
| Grow a card on hover | transform: scale() | width, height, padding | Size changes reflow siblings |
| Fade content in or out | opacity | visibility toggled per frame, display | Opacity stays on the composite path |
| Spin a loading icon | transform: rotate() | Swapping image frames | Rotation needs no repaint |
| Soften a shadow on hover | opacity of a pseudo-element that holds the larger shadow | box-shadow itself | box-shadow is a paint property |
| Change a button's color | background-color (accept the paint cost) | Nothing cheaper exists | Small area, short duration, usually fine |
| Expand an accordion | FLIP with transform, or accept layout for small panels | Long height transitions on big content | Height drives layout of everything below |
The shadow row deserves a note. Instead of transitioning box-shadow from small to large, put the large shadow on a ::after pseudo-element set to opacity: 0 and fade it in. The shadow is painted once; only its opacity animates.
.card { position: relative; }
.card::after {
content: "";
position: absolute;
inset: 0;
border-radius: inherit;
box-shadow: 0 12px 32px rgb(0 0 0 / 0.25);
opacity: 0;
transition: opacity 200ms ease-out;
pointer-events: none;
}
.card:hover::after { opacity: 1; }
Moving things with transform
Moving an element by changing left makes the browser recompute layout on every frame. Moving it with translateX produces the same picture while skipping layout and paint.
/* Layout every frame */
.panel { position: absolute; left: -320px; transition: left 300ms ease-out; }
.panel.open { left: 0; }
/* Composite only */
.panel { position: absolute; left: 0; transform: translateX(-100%); transition: transform 300ms ease-out; }
.panel.open { transform: translateX(0); }
The second version has a side benefit: translateX(-100%) is relative to the panel's own width, so the same rule works whether the panel is 280 or 420 pixels wide.
Transforms do not change layout, which is the point, but it also means surrounding content will not move out of the way. If a sidebar should push the main column over, either accept a layout animation for that one container or slide the sidebar over the content as an overlay. An overlay also leaves the Cumulative Layout Shift score alone, because no other element changes its starting point; the CLS worked examples score a cookie banner as a push and as an overlay, plus an ad slot and an accordion.
CSS, the Web Animations API, or requestAnimationFrame
All three can produce smooth motion. The property you animate decides the cost far more than the API you use.
- CSS transitions and keyframe animations suit state changes: open and closed, hover and rest, entered and exited. They are declarative, they respect
prefers-reduced-motionmedia queries in the same stylesheet, and the browser knows the whole timeline in advance. - The Web Animations API (
element.animate(keyframes, options)) gives JavaScript control over the same kind of keyframe animation. MDN listsElement.animate()as Baseline widely available since March 2020 and notes that it returns anAnimationobject, which you can pause, reverse, or await. It fits interactions where the start and end values are only known at runtime, such as FLIP. - requestAnimationFrame loops make sense when every frame depends on fresh input: a physics simulation, a canvas drawing, a value driven by pointer position. They are also the easiest place to cause jank, because a loop that reads layout (
getBoundingClientRect,offsetHeight) and then writes styles forces the browser to compute layout mid-frame. If you must read and write, do all the reads first, then all the writes.
Containing paint and layout work
Sometimes a paint-level animation is unavoidable: a progress bar that changes color, a chart that redraws. CSS containment limits how far the work spreads. MDN describes contain: layout as isolating an element's internal layout from the rest of the page, and contain: paint as clipping descendants to the element's bounds. The content keyword is shorthand for layout paint style, and strict adds size.
.live-widget {
contain: content; /* layout + paint + style */
}
MDN adds a caution worth repeating: layout, paint, content and strict each create a new containing block, stacking context and block formatting context. That can change how absolutely positioned children and z-index behave, so test the component after adding containment.
will-change and layer promotion
will-change: transform hints that an element is about to animate, so the browser can promote it to its own compositor layer before the first frame instead of during it. That can remove a stutter at the start of an animation. It also has real costs.
MDN's guidance is unusually blunt. It calls will-change a last resort for existing performance problems, says not to use it to anticipate problems, and warns that overusing it can slow a page down. web.dev's compositor article adds the reason: every layer requires memory and management, and promoting many elements, for example with a * selector, leads to layer explosions that hurt low-memory devices most.
Rules that follow from those sources:
- Add the hint shortly before the animation and remove it afterwards. MDN's own example sets
willChangeonmouseenterand resets it toautowhen the animation ends. - Never put
will-changein a global rule or on long lists of items. - Profile first. web.dev recommends promoting an element only if you notice graphics issues and think a new layer would help.
- Remember side effects. MDN notes that a value such as
will-change: opacitycreates a stacking context up front, and that the property applies to the element's whole subtree.
const card = document.querySelector(".card");
card.addEventListener("pointerenter", () => {
card.style.willChange = "transform";
});
card.addEventListener("transitionend", () => {
card.style.willChange = "auto";
});
FLIP: animating a layout change cheaply
Some changes really are layout changes: a list item moving to a new position after sorting, a thumbnail expanding into a detail view, a card jumping between columns. FLIP lets the layout change happen instantly and then fakes the motion with a transform.
- First: measure where the element is now.
- Last: apply the new layout and measure again.
- Invert: apply a transform that moves the element back to where it started, so nothing appears to have changed.
- Play: animate that transform to none.
The browser performs one layout (the real change) and then animates only a transform.
function flip(el, applyChange) {
const first = el.getBoundingClientRect();
applyChange();
const last = el.getBoundingClientRect();
const dx = first.left - last.left;
const dy = first.top - last.top;
const sx = first.width / last.width;
const sy = first.height / last.height;
return el.animate(
[
{ transformOrigin: "top left", transform: `translate(${dx}px, ${dy}px) scale(${sx}, ${sy})` },
{ transformOrigin: "top left", transform: "none" }
],
{ duration: 250, easing: "ease-out" }
);
}
Worked example with stated inputs
Take a card in a grid that moves when the user sorts by date. Before the sort, getBoundingClientRect() reports left 40, top 120, width 200, height 150. After the sort, the card sits at left 320, top 80 and keeps its size.
- dx = 40 minus 320 = -280 px
- dy = 120 minus 80 = 40 px
- sx = 200 / 200 = 1, sy = 150 / 150 = 1
The first keyframe is translate(-280px, 40px) scale(1, 1), which paints the card exactly where it was. Over 250 ms it slides to its real position. If the card also grew to 300 by 225 after the sort, sx and sy become 0.667, so the animation starts at two-thirds size and scales up.
One caution: scaling a box also scales its text and borders, so a large size change can look stretched mid-animation. For big size changes, animate a wrapper and counter-scale the inner content, or cross-fade between the two states instead.
Accordions and height
Height is the classic hard case, because the final height is usually unknown and animating it moves everything below. Options, from cheapest to most expensive:
- Avoid animating height. Fade and slightly translate the panel content in, and let the panel open instantly. Readers rarely miss the growth.
- FLIP the content below. Open the panel instantly, then FLIP the following sections from their old positions. Only transforms animate.
- Accept the layout cost for small panels. A 200-pixel FAQ answer opening once on click is not a scrolling animation running continuously. Measure it under CPU throttling, and if frames stay green, ship it.
Whichever you choose, keep the opened content in the DOM and readable by assistive technology, and toggle aria-expanded on the button that controls it.
Measuring in Chrome DevTools
A fast laptop hides problems. Measure on throttled hardware or a real mid-range phone.
Performance panel
- Open DevTools, choose Performance, and in Capture settings set CPU throttling. Chrome's reference page describes the 2x slowdown option as making the CPU run at half speed, and it offers a Calibrate feature to build presets that match real low-end devices.
- Tick Screenshots if you want a frame-by-frame filmstrip.
- Record, trigger the animation, stop.
- Read the Frames track. Chrome documents green as a frame rendered on time, yellow with a sparse dash pattern as partially presented, and red with dense lines as dropped.
- Click a long frame and look at the Main track. Chrome colors scripting dark yellow and rendering purple. Wide purple blocks labeled Recalculate Style or Layout during your animation mean you are animating a layout property, or JavaScript is forcing layout. Chrome can draw arrows from a style or layout invalidation to the event it caused, which points you at the line responsible.
Rendering tab
Open it from the DevTools menu under More tools.
- Paint flashing flashes repainted areas green. A compositor-only animation should show little or no green while it runs. If the whole viewport flashes, something above the animated element is repainting.
- Layer borders outlines layers in orange and olive, with tiles in cyan, so you can confirm that the animated element got its own layer and that you have not promoted dozens by accident.
- Frame Rendering Stats places an overlay in the top-right corner with an estimated frame rate, a frame timeline, GPU raster status and GPU memory use.
- Emulate CSS media feature prefers-reduced-motion lets you test the reduced-motion version of every animation without changing operating system settings.
web.dev's animations guide offers a matching rule of thumb: a nonzero Rendering value in the Summary tab during an animation suggests layout work, and a high-performance animation shows a very high share of frames not dropped.
Worked example: a modal that stutters
This is an illustration with stated inputs, not a measured benchmark. A settings modal opens with a combined grow and fade, and testers report stutter on mid-range phones.
Starting point. The modal transitions width, height and opacity from 0 to their final values.
.modal {
transition: width 300ms ease, height 300ms ease, opacity 300ms ease;
}
What the trace shows. With 2x CPU throttling, the Frames track shows yellow and red frames during the 300 ms, and each frame on the Main track has a purple Layout block, because width and height change the geometry of the modal and its text every frame.
The fix. Render the modal at its final size from the start and animate a scale plus opacity. Using a class rather than the hidden attribute matters here: hidden sets display: none, and a transition cannot run from an element that is not rendered.
.modal {
transform: scale(0.95);
opacity: 0;
visibility: hidden;
pointer-events: none;
/* visibility flips only after the fade-out finishes */
transition: transform 250ms ease-out, opacity 250ms ease-out, visibility 0s linear 250ms;
}
.modal.is-open {
transform: scale(1);
opacity: 1;
visibility: visible;
pointer-events: auto;
transition: transform 250ms ease-out, opacity 250ms ease-out, visibility 0s;
}
@media (prefers-reduced-motion: reduce) {
.modal { transform: none; transition: opacity 150ms linear, visibility 0s linear 150ms; }
.modal.is-open { transition: opacity 150ms linear, visibility 0s; }
}
The visibility lines matter as much as the transform. A closed modal at opacity: 0 is still there: it would catch clicks meant for the page underneath, and its buttons would stay in the tab order and in the accessibility tree. Hidden visibility removes it from all three, and the delayed visibility transition keeps the fade-out visible before that happens.
What to check afterwards. Record again with the same throttling. The purple Layout blocks inside the animation window should be gone, and Paint flashing should show little more than the first frame. If frames are still dropped, look at what else runs at the same moment: focus management scripts, a backdrop with backdrop-filter: blur() (check its Paint blocks in the trace), or a large DOM being inserted on open.
The general method works for any stutter: record, find the long frame, read which stage dominates (Scripting, Layout, Paint), and replace the property or the script that causes it.
Timing and easing
These are editorial starting values, not figures from a standard. Adjust them by testing with real content.
| Kind of motion | Starting duration | Easing |
|---|---|---|
| Hover, press, toggle feedback | 100 to 200 ms | ease-out |
| Small element entering (tooltip, menu) | 150 to 250 ms | ease-out |
| Element leaving | Slightly shorter than its entrance | ease-in |
| Large surface (modal, drawer, page panel) | 250 to 400 ms | ease-out to enter, ease-in to exit |
| Element moving within the view | 200 to 350 ms | ease-in-out |
| Continuous motion (spinner, progress) | Loop | linear |
Longer is not more polished. A menu that takes half a second to open makes every click feel slow, and people who use the interface daily notice it most. If your system defines motion tokens, put these values there; the design system build guide covers how to name and document tokens so every team uses the same durations.
Reduced motion and WCAG
Performance is only half of motion quality. WCAG 2.2 has three success criteria that bear directly on animation.
Animation from Interactions (2.3.3, Level AAA). The W3C Understanding document explains that some people with vestibular disorders get dizziness, nausea or headaches from non-essential motion, and names parallax scrolling as a common example. It is AAA, so not required for AA conformance, but it describes the reason the prefers-reduced-motion preference exists. The same document defines motion animation as steps that create the illusion of movement, and says changes only in color, blur or opacity do not count. That gives a sourced basis for the usual fallback: replace movement with a short fade.
Pause, Stop, Hide (2.2.2, Level A). Moving, blinking or scrolling content that starts automatically, lasts more than five seconds and runs alongside other content needs a way to pause, stop or hide it. The Understanding page says five seconds was chosen because it is long enough to get attention, and that auto-updating content gets no five-second exception. Auto-advancing carousels fall in this territory, so give them a visible pause control.
Three Flashes or Below Threshold (2.3.1, Level A). Content must not flash more than three times in any one-second period unless the flashes are below the general and red flash thresholds. The Understanding page treats saturated red separately because people are more sensitive to red flashing.
Writing the reduced-motion rules
MDN lists prefers-reduced-motion as Baseline widely available since January 2020. Readers turn it on in their operating system, and MDN documents where:
| Platform | Setting path (from MDN) |
|---|---|
| Windows 11 | Settings > Accessibility > Visual Effects > Animation Effects |
| Windows 10 | Settings > Ease of Access > Display > Show animations in Windows |
| macOS Sequoia (15) and earlier | System Settings > Accessibility > Display > Reduce motion |
| macOS Tahoe and later | System Settings > Accessibility > Motion > Reduce motion |
| iOS | Settings > Accessibility > Motion |
| Android 9 and later | Settings > Accessibility > Remove animations |
A blanket reset that sets every duration to near zero is a reasonable safety net, but it also removes useful fades and can break JavaScript that waits for transitionend. A better pattern is to write motion inside a no-preference query, so reduced motion is the default and movement is opt-in:
.toast { opacity: 0; visibility: hidden; transition: opacity 150ms linear, visibility 0s linear 150ms; }
.toast.is-visible { opacity: 1; visibility: visible; transition: opacity 150ms linear, visibility 0s; }
@media (prefers-reduced-motion: no-preference) {
.toast { transform: translateY(16px); transition: opacity 200ms ease-out, transform 200ms ease-out, visibility 0s linear 200ms; }
.toast.is-visible { transform: none; transition: opacity 200ms ease-out, transform 200ms ease-out, visibility 0s; }
}
In JavaScript, check window.matchMedia("(prefers-reduced-motion: reduce)").matches before starting Web Animations API or scroll-driven effects, and listen for its change event so the page responds if the setting changes mid-session.
Design rules that go with the code:
- Every animation needs a meaningful end state. Content that only exists mid-animation is lost to anyone with motion reduced, and to anyone whose script fails.
- Large parallax, zooming heroes and perpetual floating elements are the effects most likely to trigger vestibular symptoms. Use them sparingly even for readers without the setting.
- Autoplay pauses on hover and focus and never hides content behind motion.
- Lottie and video loops count too. If you embed animations from a library, the Lottie licensing guide covers rights, and the same reduced-motion check applies to the player.
Common mistakes
- Animating
all.transition: all 300msanimates every property that changes, including width or padding set by a class added later. List properties explicitly. - Fixing jank with will-change everywhere. It moves the cost into GPU memory and can make things worse on the devices that already struggle.
- Animating SVG geometry attributes for icons when a CSS transform on the group would do. The guide to cleaning up SVG exports shows how to structure icons so transforms target clean groups, and the icon design principles explain why simple shapes survive motion better.
- Testing only on a fast machine. Throttle the CPU in every recording you rely on.
- Reading layout inside an animation loop. One
offsetHeightread after a style write forces a synchronous layout on every frame. - Animating huge blurred or filtered layers.
filter: blur()andbackdrop-filtercan be expensive over large areas; record a trace, look at the Paint blocks, and if they are large, shrink the filtered area or pre-render the blur into an image. For the contrast side of the same frosted panels, see the glassmorphism text contrast guide. - Using animated GIFs for interface motion. A GIF plays the same way for every reader, so CSS cannot swap it for a still frame when reduced motion is on, and a looping GIF has no pause control; see the image format decision guide for alternatives.
Pre-ship checklist
- Every animated property is transform or opacity, or there is a written reason why not
- No
transition: all - will-change added only where profiling showed a benefit, and removed after use
- Recorded with CPU throttling; Frames track shows no red frames during the animation
- Paint flashing shows no large repaint while the animation runs
- Reduced-motion version tested with the DevTools emulation
- Auto-playing motion longer than five seconds has a pause control
- Nothing flashes more than three times per second
- Content is fully visible and usable when no animation runs
Frequently asked questions
Why does my animation look smooth on my laptop but stutter on phones?
A fast desktop CPU can absorb layout work that a slower phone CPU cannot, and a phone with a 90 or 120 Hz screen has less time per frame than a 60 Hz monitor. Record with CPU throttling in DevTools; if Layout or Paint blocks appear inside the animation, the animated property is the cause.
Does transform: translateZ(0) still help?
web.dev mentions translateZ(0) only as a fallback for browsers without will-change. Both force a layer, and both carry the same memory cost, so neither should be a default.
Can CSS custom properties be animated?
Yes, once the property is registered with @property and a typed syntax. MDN's example registers --progress with the syntax <percentage> and animates it from 25% to 100% inside a gradient. MDN marks @property as Baseline 2024, working across current browsers since July 2024, so older browsers may jump between values instead. The cost then depends on where the variable is used: a custom property feeding transform stays cheap, while one feeding width triggers layout like any width change.
Is opacity always safe under reduced motion?
The WCAG Understanding document for Animation from Interactions says opacity, color and blur changes alone are not motion animation. Short fades are a reasonable replacement for movement. Flashing opacity is a separate issue covered by the three-flash rule.
What is a good target if users have 120 Hz screens?
Aim for no dropped frames at 60 Hz under throttling first. A compositor-only animation that passes that test usually scales to higher refresh rates; a layout-bound one will not, because an 8.33 ms window leaves almost no room for layout.
Where these numbers come from
- web.dev, Rendering performance (pipeline stages, 16.66 ms, 10 ms guidance, three pipeline paths): https://web.dev/articles/rendering-performance, checked October 22, 2026
- web.dev, How to create high-performance CSS animations (transform and opacity, will-change advice, DevTools checks): https://web.dev/articles/animations-guide, checked October 22, 2026
- web.dev, Stick to compositor-only properties and manage layer count: https://web.dev/articles/stick-to-compositor-only-properties-and-manage-layer-count, checked October 22, 2026
- MDN, will-change: https://developer.mozilla.org/en-US/docs/Web/CSS/will-change, checked October 22, 2026
- MDN, contain: https://developer.mozilla.org/en-US/docs/Web/CSS/contain, checked October 22, 2026
- MDN, @property: https://developer.mozilla.org/en-US/docs/Web/CSS/@property, checked October 22, 2026
- MDN, Element.animate(): https://developer.mozilla.org/en-US/docs/Web/API/Element/animate, checked October 22, 2026
- MDN, prefers-reduced-motion (operating system settings, Baseline status): https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-reduced-motion, checked October 22, 2026
- Chrome for Developers, Performance features reference (Frames track colors, CPU throttling, Main track): https://developer.chrome.com/docs/devtools/performance/reference, checked October 22, 2026
- Chrome for Developers, Discover issues with rendering performance (paint flashing, layer borders, frame rendering stats): https://developer.chrome.com/docs/devtools/rendering/performance, checked October 22, 2026
- W3C, Understanding SC 2.3.3 Animation from Interactions: https://www.w3.org/WAI/WCAG22/Understanding/animation-from-interactions.html, checked October 22, 2026
- W3C, Understanding SC 2.2.2 Pause, Stop, Hide: https://www.w3.org/WAI/WCAG22/Understanding/pause-stop-hide.html, checked October 22, 2026
- W3C, Understanding SC 2.3.1 Three Flashes or Below Threshold: https://www.w3.org/WAI/WCAG22/Understanding/three-flashes-or-below-threshold.html, checked October 22, 2026
Motion is one part of an accessible interface. The practical WCAG 2.2 AA guide covers the keyboard, focus and contrast checks that sit alongside these motion rules, with a release checklist you can run on the same build.