Motion and Interaction · Step 5 · 6 min read
Motion performance
Smooth motion is a budget: about 10 milliseconds of work per frame. How the browser draws a frame, why transform and opacity are cheap and width and top are not, what will-change really does, and how to check an animation instead of hoping.
An animation that stutters is worse than no animation. The point of motion is to explain a change. When it judders, it explains nothing and makes the product feel broken, and it's usually on the cheaper phones, the ones you don't test on. The fix is rarely "less motion". It's choosing what you animate, and that choice starts in the design, not in the code review.
What you'll be able to do after reading:
- Explain the frame budget in plain numbers
- Name the four steps the browser takes to draw a frame
- Say which properties are cheap to animate and which are expensive
- Check an animation in the browser's developer tools
1. The frame budget
Most screens refresh 60 times a second. To keep up, the browser has 16.66 milliseconds to make each frame, and because it has its own work to do in that time, web.dev puts the budget for your work at about 10 milliseconds. Miss it, and frames drop: the motion judders, which developers call jank (web.dev, Rendering performance).
Ten milliseconds is not much. It's why the question isn't "can we animate this?" but "what does each frame of this animation cost?"
2. Four steps, three paths
To draw a frame, the browser works through a pipeline. web.dev calls it the pixel pipeline: style (which rules apply), layout (where everything goes and how big it is), paint (filling in the pixels) and composite (putting the painted layers together on screen). What you animate decides how many steps run again on every frame (web.dev, Rendering performance):
| What you animate | Style | Layout | Paint | Composite | Cost per frame |
|---|---|---|---|---|---|
Geometry: width, height, top, left, margin, padding, font-size | Yes | Yes | Yes | Yes | Highest: the page is measured again, then repainted |
Paint only: color, background-color, background-image, box-shadow | Yes | No | Yes | Yes | Middle: fine for a small area, heavy for a large one |
Compositor: transform, opacity | Yes | No | No | Yes | Lowest: the layer is already drawn, only placed again |
left and the browser lays out and repaints every frame; move it with transform and it only composites. The three paths come from web.dev's rendering performance guide; exact costs vary by browser, so check in DevTools.Source: web.dev, Rendering performance.- Change geometry (
width,height,top,left) and the browser must lay out again, then repaint, then composite. It also has to check every element that the change might push around. - Change something that only paints (
color,background-color,box-shadow) and layout is skipped. - Change
transformoropacityand the browser can jump straight to compositing. That's the cheapest path, and the one web.dev recommends for animation: avoid properties that trigger layout or paint unless it's absolutely necessary (web.dev, How to create high-performance CSS animations).
The exact cost of a property varies between browsers and versions. Old lookup tables online are out of date, so trust a measurement in your own browser over a list.
3. Same motion, different cost
left
Moved with transform
Your device asks for reduced motion, so the squares stay still. The point survives: you couldn't tell them apart anyway.
This is the code that moves the two squares. Same distance, same 2 seconds, same easing:
.mo-c-race--left > i { animation: mo-c-by-left 2s ease-in-out infinite alternate paused; }
.mo-c-race--transform > i { animation: mo-c-by-transform 2s ease-in-out infinite alternate paused; }
@keyframes mo-c-by-left { to { left: calc(100% - 2.5rem); } }
@keyframes mo-c-by-transform { to { transform: translateX(calc(100cqi - 3rem)); } }
On a fast laptop you won't see a difference. On a busy page and a slow phone, the top one is the one that drops frames. In web.dev's own comparison of the same two techniques, the top and left version dropped 50% of its frames and the transform version only 1% (web.dev, How to create high-performance CSS animations).
What this means for design:
- Design motion that transform and opacity can do. Slide, scale, rotate, fade. A panel that slides in over the page is cheap; a panel that pushes the content aside by changing its width is expensive.
- Expanding a card? Animate a scale or a clip, then settle the layout once at the end, instead of animating the height.
- Shadows and blurs are paint. A small button's shadow is fine; a large blurred background animating every frame is not.
4. will-change: a hint, not a fix
will-change: transform tells the browser an element is about to change, so it can put it on its own layer in advance (MDN, will-change). It sounds like a free speed-up, and it isn't. Layers cost memory, and web.dev advises against reaching for it early: use it only when you see a real graphics problem, on elements that are always about to change, and remove it when the change is over (web.dev, How to create high-performance CSS animations).
For a designer, the useful habit is simpler: if a spec needs will-change everywhere, the motion is probably animating the wrong properties.
5. Check it, don't hope
You can see the cost yourself in Chrome's developer tools (Chrome for Developers, Discover issues with rendering performance):
- Open DevTools, then the Rendering panel.
- Turn on Paint flashing. Areas the browser repaints flash green. Play the demo above: only the top lane flashes.
- In the Performance panel, turn on CPU throttling to act like a slower phone, record while the animation plays, and look for long frames.
Do it once with a developer. After that you'll both talk about motion in the same terms.
6. Common mistakes
- Animating
heightto open accordions and panels. - Moving things with
topandleftinstead oftransform. will-changeon everything "to make it faster".- Large blurs, shadows or filters animating on every frame.
- Testing only on the designer's laptop.
7. Vocabulary
| Term | Meaning |
|---|---|
| Frame | One picture on screen; at 60 Hz, a new one every 16.66 ms |
| Jank | Visible stutter when frames are dropped |
| Layout | Working out the size and position of everything on the page |
| Paint | Filling in the pixels of each element |
| Composite | Assembling the painted layers into what you see |
| Layer | A part of the page painted separately, which can be moved without repainting |
will-change |
A hint that an element is about to change, so the browser can prepare a layer |
8. Try it (no tools needed)
- Think of three motions in a product you work on: a menu, a card that expands, a toast.
- For each, write the property that moves today, if you know it, or the one you'd guess.
- Rewrite each as transform or opacity. Which one is hard? That's the one to discuss with a developer.
Reflection questions: Which of your motions would suffer first on a three-year-old phone? Has anyone on the team ever looked?
9. If you already practise
- Write
transformandopacityinto the spec, not just "slide in". - Test motion on a low-end Android phone, or with CPU throttling, before sign-off.
- Add "no layout properties animated" to the motion review checklist (see Reviewing motion in critique).
- Agree a performance budget for motion with your team (see Motion, performance and budgets).
Checklist
Learn more
- web.dev: Rendering performance · How to create high-performance CSS animations · Stick to compositor-only properties and manage layer count
- MDN, will-change
- Chrome for Developers, Rendering performance in DevTools
Books, courses and videos to go deeper
- Designing Interface AnimationVal HeadBook · Rosenfeld Media, 2016 (Amazon)
- Rendering performanceweb.devfree, guide (external site)
Book links go to Amazon. As an Amazon Associate I earn from qualifying purchases, at no extra cost to you.
Related
CSS transitions and animations · Images and page speed · Motion, performance and budgets · Lottie, Rive and handing off motion · Animation performance checklist