animation-performance
Keep web animations inside the frame budget — animate composite-only properties, keep motion off the main thread when the page is busy, and find the cause when an animation drops frames. Covers the layout/paint/composite pipeline, cheaper property swaps, CSS vs WAAPI vs requestAnimationFrame, Framer Motion's hardware-accelerated path, React re-rendering per frame, inherited CSS variable recalculation, blur cost, and when `will-change` actually helps. Use when an animation is janky, choppy, stutters, or drops frames; when choosing which property to animate; when deciding between CSS and JS animation on performance grounds; or when reaching for `will-change` or GPU layers. For choosing easing, duration, or whether to animate at all use animate; for reviewing motion as a whole use review-animations.
ArcReel · 已有静态检查记录
安装与使用
运行命令前先阅读来源与依赖说明。复制命令不会自动安装或执行。
npx skills add ArcReel/ArcReel --skill animation-performance技能说明
name: animation-performance
description: Keep web animations inside the frame budget — animate composite-only properties, keep motion off the main thread when the page is busy, and find the cause when an animation drops frames. Covers the layout/paint/composite pipeline, cheaper property swaps, CSS vs WAAPI vs requestAnimationFrame, Framer Motion's hardware-accelerated path, React re-rendering per frame, inherited CSS variable recalculation, blur cost, and when will-change actually helps. Use when an animation is janky, choppy, stutters, or drops frames; when choosing which property to animate; when deciding between CSS and JS animation on performance grounds; or when reaching for will-change or GPU layers. For choosing easing, duration, or whether to animate at all use animate; for reviewing motion as a whole use review-animations.
Animation Performance
Initial Response
When this skill is first invoked without a specific question, respond only with:
I'm ready to find out why your animation drops frames and make it smooth, my knowledge comes from Emil Kowalski's design engineering philosophy.
Do not provide any other information until the user asks a question.
A diagnostic skill. It does ONE thing: make motion land every frame. It does not pick easing or duration (that's animate), judge whether the motion should exist (that's review-animations), or handle React Native's threads (that's animate-expo). The question here is never "does it look right?" but "does each frame finish in time?".
Why This Matters
Imagine Sonner running at 30fps. Same easing, same durations, same code. Nobody would have cared. Performance isn't a polish pass applied after the motion is good; it's what lets good motion register at all.
Operating Posture
You are a design engineer who has shipped drawers, toasts, and dashboards to real devices and has had each of the traps below bite in production. You know the developer's MacBook is the least representative device the animation will ever run on.
Two failure modes, and the first is worse:
- "It's smooth on my machine." A fast laptop hides almost every problem in this skill. The bar is a mid-range phone, and on a 120Hz screen the budget is half what you think.
- Sprinkling
will-changeand calling it fixed. It's the last step, not the first. Most jank is the wrong property or a busy main thread, andwill-changefixes neither.
Hard Rules
transformandopacityby default. Anything else needs a reason. If a cheaper property produces the same visual, use it, even when the expensive one "seems fine".- Name the cause before changing code. Every fix you propose names which of the causes below it addresses. "Added
will-change, seems smoother" is not a diagnosis. - Never conclude "it's fine" from a fast machine. Say which findings you verified from code and which need a recording on a real device.
- Never
transition: all. List the exact properties.allanimates whatever changes next, including layout properties nobody intended to animate. - Don't trade correctness for a best-effort optimization. Hardware acceleration is something the browser may grant. Which properties you animate is something you control. Spend effort on the second.
The Symptom Table
Start here. Match what the user is seeing, then read the matching section.
| Problem | Solution |
|---|---|
| Animation stutters | Animate transform/opacity, not width/height/top/margin |
| Shadow animation is choppy | filter: drop-shadow() |
| Jank only during navigation or loading | Move the animation to CSS or WAAPI so it runs off the main thread |
Framer Motion x/y drops frames | Animate the full transform string |
| Hand-rolled animation drops frames in React | Write to ref.current.style, not state |
| Drag gets laggier as the list grows | Stop animating an inherited CSS variable; set transform directly |
| Blur transition lags (especially Safari) | Keep animated blur() under 20px |
| Unexpected properties animate | Replace transition: all with explicit properties |
| Element shifts 1px when motion starts or ends | will-change: transform, only once you see it |
The Frame Budget
60fps is what the brain reads as fluid motion and matches most refresh rates. It gives the browser 16.7ms (1000/60) per frame. On a 120Hz screen, now most phones and many laptops, it's 8ms. Design against the smaller number.
For scale: a layout recalculation on a complex page can take over 100ms. That isn't one missed frame, it's a dozen.
Two things decide whether you stay inside the budget:
- What you animate: how much work each frame costs.
- Where it runs: whether that work can be blocked by everything else the page is doing.
What You Animate
To show a visual change, the browser runs up to three steps:
- Layout: calculate the size and position of every element.
- Paint: draw the page into layers.
- Composite: put those layers on screen.
Every property enters this pipeline at one of three points, and the cost differs by an order of magnitude:
| Tier | Properties | Cost |
|---|---|---|
| Composite only | transform, opacity, and in current Chrome/Firefox also filter, clip-path, background-color | Cheapest. Browsers promote these to their own layer. |
| Paint + composite | box-shadow, border-radius, color | No re-measuring, but a redraw every frame. |
| Layout + paint + composite | width, height, padding, margin, top, left, border-width | Most expensive. One growing element can move everything around it. |
transform and opacity change how an element looks, not where it sits in the document flow, so nothing needs re-measuring. Anything else in the composite tier needs testing across browsers and devices; support is uneven.
Swapping down a tier:
| Instead of | Animate |
|---|---|
width |