How to Build SEO-Friendly Animations

Why animations and SEO are hard to get right
Motion makes an interface feel finished. It is also one of the easiest ways to lose points in Lighthouse, and most of the damage happens quietly until the report comes back.
Search engines do not rank animations. What Google measures is the page experience around them: how quickly content appears, how stable the layout is, and how fast the page reacts to input.1 An animation only matters for SEO when it changes one of those three things.
Here is the most common way it does. Both mock pages below have the same headline. In the left one, the headline starts at opacity: 0 and waits for a script to reveal it. Move the slider to change how long the script takes, then run the simulation.
Hidden until JavaScript runs
Headline visible at press Run
Visible from the first paint
Headline visible at press Run
Simulated timing. A real page also waits for the network and rendering, but the LCP clock behaves the same way: it cannot stop on an element that is not visible yet.
The page on the right paints its largest element immediately. The page on the left cannot finish its Largest Contentful Paint until the script runs, no matter how smooth the fade looks.
How animations affect SEO
Animations rarely affect whether search engines can crawl or index your content. Their influence is indirect and runs through Core Web Vitals:
Animation → page performance and responsiveness → Core Web Vitals → SEO impact
Google uses real-user data for three metrics as part of its page experience signals.2 A careless animation can delay rendering, shift the layout or block input, and each of those lands in one of them.
| Metric | What it measures | Good | Typical animation mistake |
|---|---|---|---|
| LCP (Largest Contentful Paint) | When the main content becomes visible | 2.5 s or less | Hero starts at opacity: 0 and waits for JavaScript |
| CLS (Cumulative Layout Shift) | How much the layout jumps | 0.1 or less | Animating height, top or left, or loading unsized media |
| INP (Interaction to Next Paint) | How quickly the page responds to input | 200 ms or less | Heavy scroll and observer work on the main thread |
Lighthouse measures these in lab conditions with simulated throttling, while Search Console reports field data from real users. An animation that struggles on a slow CPU usually shows up in both sooner or later.
Where animations hurt Lighthouse scores
Most problems come from a handful of patterns. Once you can spot them, safe motion gets much easier.
Hiding content on load with JavaScript
The most common mistake is making important content invisible on load and revealing it with a script.
<!-- Don't: the hero waits for JavaScript -->
<h1 data-reveal>Build fast websites</h1>
// ...and only becomes visible after this runs
const observer = new IntersectionObserver(/* ... */);
observer.observe(document.querySelector('h1[data-reveal]'));
A CSS transition does not change the outcome. On a fast laptop the delay is a few milliseconds. On a mid-range phone with a slow connection it can be seconds, and both the visitor and the audit see a blank hero for that long.
LCP and what NO_LCP means
“Above the fold” is the initial viewport: what a visitor sees before scrolling, usually the header, the hero headline, the main call to action and often a hero image. The term comes from newspapers, where the best headlines sat on the top half of a folded front page.
If that area is late or jumps around, LCP and CLS degrade quickly. The rule of thumb: critical above-the-fold content should be visible immediately, without waiting for animation JavaScript.
Avoid above the fold
- Starting the hero headline or image at
opacity: 0,visibility: hidden,display: noneorscale(0) - Gating the hero or header behind an
IntersectionObservercallback - Delaying critical UI with reveal JavaScript, even when the CSS transition is smooth
Do above the fold
- Render critical content at full opacity immediately
- Reserve space for media with explicit dimensions or
aspect-ratio, so the layout does not jump - Keep motion small and non-blocking: hover states and subtle decorative movement
Chromium ignores elements at opacity: 0 when it picks an LCP candidate, so a headline that starts hidden does not count until it becomes visible.3 When Lighthouse reports NO_LCP, it did not record a Largest Contentful Paint during its audit. A common cause is exactly this setup: the largest element, often the hero image or the <h1>, starts hidden and is revealed by script, so the audit never sees a qualifying paint.
Backgrounding the tab or navigating away before the page settles can produce the same result, but a hidden hero is the first thing to check.
Layout animations and CLS
Animating layout properties can push content around and hurt CLS. The example below is risky because every frame of the transition changes the size of the panel and moves everything under it.
/* Risky for CLS */
.panel {
height: 0;
transition: height 300ms ease;
}
.panel.is-open {
height: 220px;
}
height, width, top and left can all move other elements, and so can inserting media without dimensions. Press play to see it measured. Both versions show the same banner, and the page reports how far the paragraph underneath moved.
Animates height
height: 0 to 88px
The paragraph you were reading.
Content moved by press Play
Animates transform
space reserved, then opacity and translateY
The paragraph you were reading.
Content moved by press Play
Both versions show the same banner. The page measures the position of the paragraph underneath before and after the animation, so the number is real, not scripted.
The safer pattern has two parts:
- Reserve space up front, with
aspect-ratioor fixed dimensions, so nothing has to move when content appears. - Animate
transformandopacityinstead of layout properties.
Animating left from 0 to 100px typically forces layout work on every frame. Animating transform: translateX(100px) usually avoids layout entirely and can run on the compositor, often on the GPU. These recommendations line up with Google’s guidance on high-performance CSS animations.4
Heavy animation scripts and INP
IntersectionObserver is not the problem. Observing hundreds of nodes and doing expensive work in the callback is, especially on low-end phones, because that work competes with the main thread when someone taps or types. INP is sensitive to long tasks that overlap with input.
The habits that keep reveal code cheap:
- Keep observer callbacks short: add a class and return.
- Skip layout reads such as
getBoundingClientRect(),offsetHeightandgetComputedStyle(). Every observer entry already carriesboundingClientRectandintersectionRatio. - Defer anything expensive, such as asset loading or heavy setup, with
requestIdleCallback(with a fallback),scheduler.postTask()where available, orsetTimeout.
A two-layer model for animations
Split the interface by when the visitor sees it.
Above the fold is the critical layer. It is static by default, visible and stable from the first paint.
- Header and navigation: people need to know where they are immediately.
- Hero: the headline, main image and call to action render at once.
- Main content and forms: on a task page such as login or contact, do not fade anything in.
- Trust signals: show credibility indicators immediately.
Below the fold is the enhancement layer. Reveals, stagger and decoration all belong here.
- Feature grids and cards
- Testimonials and case studies
- Related-content lists and carousels
- Decorative shapes and secondary imagery
- Footers and newsletter sections
Everything a visitor needs in the first second should be visible and stable. Everything else is a candidate for animation.
Different pages get different animation budgets
Not every page deserves the same amount of motion.
| Page type | Examples | Motion budget | Why |
|---|---|---|---|
| Discovery | Home, landing pages, blog lists | Medium to high | People browse, and motion can guide attention |
| Reading | Blog articles, docs | Low | Anything that distracts from the text is expensive |
| Task | Contact, login, checkout | Minimal | The goal is to finish, so clarity and speed beat delight |
Safe animation patterns
With those rules in place, here are patterns that hold up in production. They all use the same names: a data-reveal attribute for elements that animate, an is-visible class once they have, a --delay custom property for stagger, and a js class on the root element.
Progressive enhancement for scroll reveals
Keep content visible by default. Hide it only when JavaScript is running and the visitor has not asked for reduced motion, and only for elements below the fold. Everything above the fold simply has no data-reveal attribute.
/* Baseline: visible for everyone */
[data-reveal] {
opacity: 1;
transform: none;
}
/* Enhancement: only with JavaScript, and only when motion is welcome */
@media (prefers-reduced-motion: no-preference) {
.js [data-reveal] {
opacity: 0;
transform: translateY(20px);
transition:
opacity 0.5s ease-out var(--delay, 0s),
transform 0.5s ease-out var(--delay, 0s);
}
.js [data-reveal].is-visible {
opacity: 1;
transform: none;
}
}
<head>
<!-- Inline and early, so below-the-fold elements never flash visible and then hide -->
<script>
document.documentElement.classList.add('js');
</script>
</head>
<body>
<!-- Critical content: no attribute, visible immediately -->
<section class="hero">
<h1>Build fast websites</h1>
</section>
<!-- Below the fold: enhanced -->
<section class="features" data-reveal>
<h2>Features</h2>
</section>
</body>
const STEP = 60; // ms between items that reveal together
const MAX_STAGGER = 3; // so no item waits more than 180 ms
const targets = document.querySelectorAll('[data-reveal]');
const reducedMotion = matchMedia('(prefers-reduced-motion: reduce)').matches;
if (reducedMotion || !('IntersectionObserver' in window)) {
targets.forEach((el) => el.classList.add('is-visible'));
} else {
const observer = new IntersectionObserver(
(entries) => {
// Entries arrive in the order you observed them
entries
.filter((entry) => entry.isIntersecting)
.forEach((entry, i) => {
const el = entry.target;
// An inline --delay in the markup wins
if (!el.style.getPropertyValue('--delay')) {
el.style.setProperty('--delay', `${Math.min(i, MAX_STAGGER) * STEP}ms`);
}
el.classList.add('is-visible');
observer.unobserve(el);
});
},
{ rootMargin: '0px 0px -10% 0px', threshold: 0.1 },
);
targets.forEach((el) => observer.observe(el));
}
This is the code running in the box below. Scroll it. The first items are already inside the box, so they reveal together with a small stagger, and the rest reveal as they come into view.
Revealed 7 of 7
Hero section
Above the fold. Static from the first paint.
- Feature one
- Feature two
- Feature three
- Testimonial
- Related article
- Newsletter signup
- Footer links
Same CSS and JavaScript as above, scoped to this box. The hero has no data-reveal attribute, so it never waits for anything.
Because the hiding rules sit inside prefers-reduced-motion: no-preference, visitors who ask for less motion never get hidden content, and the script reveals everything immediately.
The result: crawlers and visitors always see critical content, LCP can fire right away, and with JavaScript disabled nothing is hidden. One caveat is that if the inline script adds js but the main script never loads, below-the-fold content stays hidden. Keep the reveal script small, and be careful about loading it from a third party.
CSS scroll-driven animations
Where you can, skip JavaScript and let the browser tie the reveal to scroll position.
@keyframes fade-slide-in {
from {
opacity: 0;
transform: translateY(24px);
}
to {
opacity: 1;
transform: none;
}
}
@media (prefers-reduced-motion: no-preference) {
@supports (animation-timeline: view()) {
.scroll-fade {
animation: fade-slide-in linear both;
animation-timeline: view();
animation-range: entry 0% entry 100%;
}
}
}
animation-range: entry 0% entry 100% runs the animation while the element enters the viewport and finishes when it is fully inside.
Hero section
Above the fold. Static from the first paint.
- Feature one
- Feature two
- Feature three
- Testimonial
- Related article
- Newsletter signup
No script runs in this demo. The browser ties each item's progress to its position in the scroll box, so scrolling back up plays the animation in reverse.
No JavaScript runs here, which keeps the main thread free and helps INP. The same rule applies as before: keep it below the fold, because the animation starts at opacity: 0.
Scroll-driven animations work in Chrome and Edge 115 and later and in Safari 26 and later. Firefox enabled them by default in version 159 in October 2026, which made them Baseline Newly available.5 The @supports guard still matters for older browsers, and without support the items simply stay visible, as the demo shows.
Staggered delays for smoother reveals
A small stagger makes a group of items read as one movement instead of several pop-ins. The observer above already does it: items that intersect in the same callback get delays of 0, 60, 120 and 180 ms, and an item that scrolls in alone gets none.
That is deliberate. Giving each card a fixed delay based on its position in the DOM makes the third card wait 200 ms for no reason when it enters the viewport alone. Staggering by position in the batch avoids that.
When you do want a specific order, set --delay yourself and the observer leaves it alone:
<section class="features">
<div data-reveal style="--delay: 0ms">Feature one</div>
<div data-reveal style="--delay: 100ms">Feature two</div>
<div data-reveal style="--delay: 200ms">Feature three</div>
</section>
Keep total delays short, usually under 200 ms. Longer delays make a page feel slow and work against perceived performance.
One more detail: the delay lives inside transition, so it also applies to any hover transition on the same element later. If a revealed card has a hover effect, clear the delay once the reveal ends, right after adding is-visible:
el.addEventListener('transitionend', () => el.style.removeProperty('--delay'), { once: true });
Advanced: will-change and content-visibility
will-changeis a hint that an element is about to change, so the browser can prepare, often by promoting it to its own compositor layer. That costs memory, so use it only for genuinely heavy motion, name only the property you animate (usuallytransform), and keep it on only while the transition runs.
/* Heavy 3D motion: hint only during the transition */
.flip-card.is-flipping {
will-change: transform;
}
const card = document.querySelector('.flip-card');
card?.addEventListener('click', () => {
// Add the hint just before the flip starts
card.classList.add('is-flipping');
// Remove it when the heavy transition finishes.
// If you transition several properties, wait for `transform`.
const onEnd = (event) => {
if (event.propertyName !== 'transform') return;
card.classList.remove('is-flipping');
card.removeEventListener('transitionend', onEnd);
};
card.addEventListener('transitionend', onEnd);
});
content-visibility: autolets the browser skip most rendering work for offscreen content until the visitor scrolls near it. It suits very heavy below-the-fold sections such as long lists, complex UI and embeds. It is separate from animation: it is about not doing work yet. Reserve space withcontain-intrinsic-sizeto avoid CLS, and never apply it to critical above-the-fold content.
/* Heavy below-the-fold sections (separate from animation) */
.heavy-below-fold {
content-visibility: auto;
contain-intrinsic-size: auto 800px;
}
SEO-friendly animation checklist
Good animation for SEO is not about shipping less motion. It is about protecting the first paint and the first interaction, then treating motion as an enhancement on a page that already works.
- Keep above-the-fold content visible and stable from the first paint.
- Animate below the fold with
transformandopacity. - Respect
prefers-reduced-motion. - Keep animation JavaScript small: add a class, skip layout reads.
Check your own site
- Run Lighthouse or PageSpeed Insights and look at the LCP element it reports. If it is missing, or it is not your hero, suspect a hidden hero.
- Open DevTools, go to Performance, and turn on CPU throttling and a slow network. Look for the LCP marker and any layout shifts.
- Disable JavaScript and reload. Nothing should be missing.
- Emulate
prefers-reduced-motion: reducein the Rendering panel and confirm every reveal is gone.
When in doubt, ship it static first and enhance it later.
Footnotes
-
Google Search Central, “Understanding page experience in Google Search results”, https://developers.google.com/search/docs/appearance/page-experience ↩
-
Google, “Web Vitals”, https://web.dev/articles/vitals ↩
-
web.dev, “Largest Contentful Paint (LCP)”, which lists elements with an opacity of 0 among the exclusions in Chromium-based browsers, https://web.dev/articles/lcp. DebugBear, “How CSS Opacity Animations Can Delay The Largest Contentful Paint”, https://www.debugbear.com/blog/opacity-animation-poor-lcp ↩
-
web.dev, “How to create high-performance CSS animations”, https://web.dev/articles/animations-guide ↩
-
MDN Web Docs, “animation-timeline”, https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/animation-timeline. web.dev, “New to the web platform in October”, https://web.dev/blog/web-platform-10-2026 ↩