Technote

Performance optimization Practical

What you can animate for free, and what costs a frame

A frame is a very short budget. Only transform and opacity move without layout work; everything else charges you on every single frame.

Animation that stutters is usually not caused by too much animation but by animating the wrong property. The same visible movement can ask the browser for wildly different amounts of work depending on how it is implemented.

What the browser does inside one frame

Smooth movement lives around sixty frames per second, which leaves roughly sixteen milliseconds per frame. Inside that window the browser works through this sequence.

The rendering pipeline — animations that only touch the end are cheap

What matters is how far back you send it. Properties that change an element’s size or position rerun layout, and not only for that element — siblings and ancestors may be repositioned too, which makes it the most expensive case. Colours and shadows skip layout but rerun paint. Only transform and opacity are handled at the composite stage, leaving the earlier steps alone.

Substitutions that make the same motion cheap

Most UI animation can be rewritten with the cheap properties. The result looks essentially identical and the browser simply does less.

Moving items from the left column to the right is most of the work

Concretely: slide something across with translateX rather than left, grow it with scale rather than width. Fade things out with opacity instead of touching display or height. If a shadow needs to deepen on hover, do not animate the shadow value — put a second layer carrying the deeper shadow behind it and animate that layer’s opacity.

will-change helps, but overusing it backfires. It tells the browser to prepare a separate layer, and every layer costs memory. Apply it only to elements about to move, and remove it when they stop.

Set a budget: count, duration, concurrency

Even with the right properties, moving dozens of things at once is still slow. Deciding three things at design time makes implementation much easier.

An animation budget — the bottom two lines eat the most frames

The second-to-last line is worth explaining. If a script reads an element’s position on every scroll event and then writes styles, the browser must force pending work to finish in order to answer the read. Repeat that each frame and scrolling becomes visibly heavy. Scroll-linked effects can now be expressed in CSS alone, so moving this whole class of effect into the stylesheet is the safer route.

“Reduce motion” is a real request

Operating systems expose a reduced-motion setting and browsers pass it through as prefers-reduced-motion. For people who get dizzy or nauseated by movement, this is a need rather than a preference.

The important part of honouring it is that the default state must be the finished state. If an element only becomes visible inside an animation declaration, a reduced-motion visitor never sees the content at all. Build the static layout first and lay motion on top, and the page stays whole with motion off — and in browsers that do not support the feature at all.

Related first-screen performance topics are collected in the performance archive, and tuning motion across viewport widths is covered in the responsive series. Finding and fixing rendering bottlenecks on a live site is part of our optimization program.

More on this topic

All technotes

Performance optimization Advanced

A front-end budget you can actually hold

Pages do not get heavy in one go. They get heavy through small, individually reasonable additions. A ceiling you actually check is what stops the accumulation.

Developers 8 min read

Performance optimization Advanced

A conversion audit: finding where people leave

Polishing a page nobody reaches is the most common waste. Walk the whole path end to end and the leak shows itself first.

Marketers 7 min read

Performance optimization Practical

The cost of pop-ups — search and conversion at once

An interstitial that covers the content on mobile is treated unfavourably in search, and the same interstitial costs conversions too. The levers are timing, trigger and dismissal.

Marketers 8 min read

₩270,000 · Join the program