Notes

Scroll animations that survive a frozen page

22 October 2026 2 min read

The same scroll effect, once with a scroll listener and once with CSS scroll-driven animations. Freeze the page and compare what keeps moving.

  • Motion
  • Performance
  • CSS

Scroll-linked effects are everywhere: a reading progress bar, cards that fade in, a header that shrinks. For years they meant a scroll listener. It works until the page has something else to do.

Scroll either list while it is frozen

A scroll listener moves things

JavaScript

01
02
03
04
05
06
07
08
09

The browser runs the timeline

CSS, no script

01
02
03
04
05
06
07
08
09
Live demo. Everything runs in your browser. Now try to break it.
ScrollDriven.svelte, 155 lines

Press "Scroll and freeze the page". Both lists scroll to the bottom, and 350 ms in the main thread is blocked for 1.6 seconds, the way a long task, a heavy render or a third-party script blocks it. The better test is your own hand: press "Freeze for 1.6 s" and scroll a list with the wheel or your finger while it is frozen.

What you should see

The left list is driven by JavaScript. Its bar and its cards are updated by a scroll listener, which runs on the main thread. While that thread is busy the listener waits, so the effect stands still and then jumps.

The right list uses scroll-driven animations. They are built so that a browser can run animations of transform and opacity away from the main thread, which is the point: the effect no longer depends on a thread that may be busy. How much of that you get depends on the browser and the device, so do not trust this page or any article. Freeze it on the phone you care about, scroll with your finger, and see.

The whole "after" version

.bar {
  transform-origin: left;
  animation: fill linear both;
  animation-timeline: scroll(nearest block);
}

.card {
  animation: reveal linear both;
  animation-timeline: view(block);
  animation-range: entry 0% entry 100%;
}

@keyframes fill   { to   { transform: scaleX(1); } }
@keyframes reveal { from { opacity: 0.15; transform: scale(0.92) translateY(16px); } }

There is no listener, no getBoundingClientRect and no layout read in the scroll path. The animation has no duration. Its progress is the scroll position.

  • scroll() ties an animation to how far a scroller has scrolled. That is the reading progress bar.
  • view() ties it to how far an element has moved through the scroller's viewport. That is reveal on scroll.
  • animation-range says which part of that journey the animation covers.

Ship it as an enhancement

Support is good in Chromium browsers and is arriving elsewhere. Check caniuse for the browsers you care about. The rule that keeps it safe is the same as for any enhancement: the page must be complete without it.

@supports (animation-timeline: scroll()) {
  .card { animation: reveal linear both; animation-timeline: view(block); }
}

In the demo the right list does exactly that. Where it is not supported, the cards are simply there at full strength. Nothing is hidden until some script arrives.

Rules that keep it smooth

  • Animate transform and opacity only. Width, height and top bring back layout work on every scroll step.
  • Respect reduced motion. Turn the animation off inside prefers-reduced-motion: reduce.
  • Keep JavaScript for logic. If a click handler needs the scroll position, read it there. Do not use it to paint.

Keep a busy page

Test scroll effects on a page that is doing something else: a large render, a tracking script, a throttled CPU in DevTools. If the effect only works on an idle page, it works on your laptop and not on a phone.

Related

How bright was it?

Five lamps and an optional line. Feedback, a bug, an idea, anything. I read every one and sum them up once a month.

Pick a lamp

Stored without name, address or cookie, and deleted after a year. Details in the privacy notice.