Animation and Core Web Vitals: keep the motion, keep LCP, CLS and INP

A hero that fades in late costs LCP, a growing banner costs CLS, a heavy library costs INP. Measured side by side, with the fix for each.

Updated 7 min readperformancecore-web-vitalslcpclsinplighthouse

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

The short answer

  1. LCP: never hide the hero (opacity: 0) until a script fades it in. Paint it on the first frame and let the entrance be a small movement on something already visible.
  2. CLS: animate transform and opacity, never height, top or margin on content that has other content below it. Overlay what appears (a banner, a toast) instead of pushing the page.
  3. INP: keep animation code off the main thread's busiest moments: CSS or the Web Animations API over per-frame JavaScript, and load big animation libraries only on pages that use them.
  4. Check with Lighthouse: "Avoid non-composited animations" lists every animation that moves layout or repaints, with the property to blame.

Motion and page speed only fight when the motion is built the expensive way. Google's three Core Web Vitals each have one animation habit that hurts them, and one cheap fix. We built each pair as a tiny page and measured it with Lighthouse 12.8 (desktop, no throttling), so the numbers below are the effect of the animation alone.

LCP: the hero that waits for a script

Largest Contentful Paint is when the biggest thing in view, usually the headline or hero image, is painted. An element at opacity: 0 does not count as painted. So the popular "fade the hero in once JavaScript loads" pattern moves LCP to whenever the fade starts.

Page LCP Performance score
Hero at opacity: 0, a script fades it in after 1.2 s 2.0 s 91
Hero painted at once, a CSS entrance moves it 12 px 0.0 s 100

The fix keeps the motion. Make the first frame the readable one, and animate only movement:

@media (prefers-reduced-motion: no-preference) {
  .hero h1 { animation: rise .5s cubic-bezier(.2, .7, .2, 1) both; }
}
@keyframes rise { from { transform: translateY(12px); } }

No opacity: 0 start, no script to wait for. On a real site, with fonts and a framework to load, the hidden version costs far more than our 2 s: everything before the script runs is added.

CLS: the banner that pushes the page

Cumulative Layout Shift adds up how far visible content jumps without you asking. An animation that changes layout is a layout shift on every frame.

Page CLS Lighthouse "non-composited animations"
A welcome banner grows from height: 0 to 120 px, pushing the page down 0.028 flagged: height
The same banner slides down over the page with transform 0 none
A card animates left and box-shadow 0.04 flagged: left, box-shadow
The same card animates transform, its shadow is a pseudo-element fading with opacity 0 none

Google's "good" threshold for CLS is 0.1 for the whole visit, so one banner using a quarter of the budget on load is a lot. The fix is the same both times: animate transform and opacity, and give anything that appears its own space (position: fixed, or space reserved in the layout from the first frame).

.banner { position: fixed; inset: 0 0 auto; transform: translateY(-100%); transition: transform .4s; }
.banner.open { transform: none; }

An accordion that must push content down is a layout change on purpose, and that is fine when the visitor clicked it: shifts within half a second of a click or a key press do not count toward CLS. Animate it with the newer interpolate-size: allow-keywords and height: auto, or a grid-rows trick, rather than measuring heights in script.

Live demoA banner that pushes vs one that overlays

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

Show a banner at the top of a small article, by height or by transform into space the page kept for it. The readout measures, every frame, how far the paragraph below moved. By height it moves the full 56 px over many frames, and each of those frames is a layout shift; by transform it moves 0 px. With reduced motion the banner appears without travel, and the push still shows: 56 px in one frame.

INP: animation code competing with clicks

Interaction to Next Paint measures how long the page takes to answer a click, tap or key. Animations hurt it when they run in JavaScript on every frame, or when a large animation library has to load and start before the page can answer. What helps:

  • CSS transitions and the Web Animations API (element.animate()) for anything that can be expressed as keyframes. Transform and opacity animations then run on the compositor and keep going even when the main thread is busy.
  • One requestAnimationFrame loop, not one per element, for the rare animation that really must be computed each frame (physics, a canvas), and stop it when it is off-screen or finished.
  • Load heavy motion only where it is used. A 40 to 60 KB animation library imported on every page, to fade one button, is paid for by every visitor on every page. Import it in the one component that needs it, or use a small finished piece instead. In one of our customer tests, an icon swap pulled in 39 KB of shared code it did not need; that was a bug in our piece, now fixed, and the kind of thing worth checking in your bundle report.

Check your own pages

Lighthouse in Chrome DevTools (Lighthouse tab → Analyze page load) runs the same audits. Look for:

  • Largest Contentful Paint element: if it is your hero, check it is not starting invisible.
  • Avoid large layout shifts: lists the elements that moved and by how much.
  • Avoid non-composited animations: every animation that cannot run on the compositor, with the property to blame (Unsupported CSS Property: height).

Field data matters more than one lab run. If your site has enough traffic, Search Console's Core Web Vitals report and the Chrome UX Report show what real visitors got.

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.