Why your animation stutters, and how to fix it

Jank has four usual causes: the property you animate, layout reads in write loops, too much work per frame, and will-change everywhere. Find and fix each.

Updated 7 min readperformanceanimationcssjavascriptdevtools

Tested 28 October 2026 with Chromium 153, Lighthouse 12.8.2On this page: 1 live demo

The short answer

  1. Animate transform and opacity only. Width, height, top, left, margin, padding and large shadows make the browser redo layout or paint on every frame.
  2. In scripts, read every measurement first, then write every style change. Interleaving them forces a fresh layout per element.
  3. Keep each frame's work small: one requestAnimationFrame loop, no heavy work on scroll or pointer events, and stop loops that are off-screen.
  4. Use will-change for an element you are about to animate, not on everything; remove it when the animation ends.
  5. Record the stutter in DevTools (Performance panel) and read what fills the long frames before you change code.

A browser has about 16 milliseconds to draw each frame on a 60 Hz screen, and 8 on a 120 Hz one. Animation stutters when a frame takes longer and the browser drops it. Almost every case comes from one of four causes, and each has a quick test.

1. The property you animate

The browser draws a frame in stages: style, layout (where things go), paint (filling pixels) and composite (stacking finished layers). transform and opacity changes can skip straight to the last stage and run on the compositor, even while the main thread is busy. Almost everything else reruns layout or paint, every frame, for everything affected.

/* stutters: layout every frame */
.panel.open { left: 0; transition: left .3s; }

/* smooth: compositor only */
.panel { transform: translateX(-100%); transition: transform .3s cubic-bezier(.2, .7, .2, 1); }
.panel.open { transform: none; }

Two common traps:

  • transition: all animates every property that changes, including ones you never meant to animate (a width change from a font loading, a colour on hover that also moves the border). Name the properties: transition: transform .3s, opacity .3s.
  • Shadows. Animating box-shadow repaints the area around the element every frame. Put the shadow on a pseudo-element and fade its opacity instead.

Lighthouse lists these for you. On our test page, a card animating left and box-shadow was flagged under "Avoid non-composited animations" with Unsupported CSS Property: left and box-shadow, and added layout shift; the same motion with transform plus a fading pseudo-element was not flagged at all (numbers in the page-speed guide).

Live demoJanky vs smooth, measured on your device

The live demo loads here when scripts run. The text below says what it shows.

The same work two ways: each frame moves a marker and resizes 300 bars. Janky moves the marker with left and reads then writes each bar in turn, forcing a fresh layout per bar. Smooth moves it with transform and does every read before every write. The readout is measured in your browser while it runs: script time per frame, the longest gap between frames, and a strip of the last 120 frames against the 16.7 ms budget. On our test machine (Chromium 153, desktop, 28 Oct 2026) the janky version spent 27 ms of script per frame and missed the budget on 132 of 165 frames; the smooth one spent 0.2 ms and missed none of 300. Nothing runs until you press a button, and each run stops after 5 seconds.

2. Reading layout inside a write loop

Reading offsetWidth, getBoundingClientRect(), scrollTop or getComputedStyle() right after changing a style makes the browser lay out the page now to answer you. Do it in a loop and you lay out the page once per element:

// slow: read, write, read, write… one layout per row
for (const row of rows) {
  const w = row.offsetWidth;
  row.style.width = (w + 1) + 'px';
}

// fast: all reads, then all writes… one layout
const widths = rows.map(row => row.offsetWidth);
rows.forEach((row, i) => { row.style.width = (widths[i] + 1) + 'px'; });

On our 500-row test page, the interleaved loop took about 59 ms per pass and the batched one about 1.1 ms: the same result, 50 times faster, and the difference between three dropped frames and none.

Animation libraries and FLIP-style list animations do the batching for you, which is one good reason to use a finished one instead of measuring by hand.

3. Too much work per frame

  • Scroll and pointer handlers fire many times per frame. Do not compute layout or start animations in them directly; record the value and do the work once in the next requestAnimationFrame, or use CSS scroll-driven animations, which need no handler at all.
  • One loop, not many. Ten components each running their own requestAnimationFrame loop is ten callbacks per frame. Share one, and stop it when nothing is moving.
  • Off-screen loops. A looping background or canvas below the fold still costs every frame. Pause it with an IntersectionObserver when it leaves the viewport, and when the tab is hidden (document.visibilityState).
  • Big blurs and filters. filter: blur() and backdrop-filter on large areas are expensive to repaint. Keep them small, or static.

4. will-change as a cure-all

will-change: transform asks the browser to put an element on its own layer before it animates, which removes a hitch at the start. But every layer costs graphics memory, and "will-change on everything" can make a page slower and blurrier, especially on phones. Use it for the one element that is about to move, and set it back to auto when the motion is done.

Find it: the Performance panel

  1. Open DevTools → Performance, press record, do the thing that stutters, stop.
  2. In the Frames row, red or long frames are the dropped ones. Click one.
  3. In the Main track below, look at what fills that frame: purple Layout blocks point to causes 1 and 2; green Paint to large repaints and shadows; yellow Scripting to cause 3.
  4. A Forced reflow warning on a Layout block links to the line of code that read layout after a write.

Then test on a mid-range phone, or with CPU throttling 4× in the same panel: an animation that is smooth on a fast laptop is not proof.

Something here did not work?

Every command on this page was run before it was published, on the systems named in "How we tested this". If a step fails for you, write to [email protected] with what you ran and what you saw, and we will fix the page.