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 Practical

Who pays for the milliseconds a tag adds?

A tracking script does not stop at downloading. While it is parsed and executed the main thread is busy, and a busy page ignores fingers. That cost is…

Marketers 5 min read

Performance optimization Practical

The object cache: what Redis actually removes

Repeated identical lookups disappear. One slow query does not. Miss that distinction and you will wire up Redis and then ask why nothing got faster.

Developers 7 min read

Performance optimization Practical

This is how a landing page gets heavy

Nobody decides to make a landing page heavy. It accumulates: one addition per campaign, and nothing ever removed when the campaign ends.

Marketers 6 min read

₩270,000 · Join the program