Mechanical ComparisonrequestAnimationFrame & VSync: Baseline · WidelyScroll-Driven Animations: Experimental

requestAnimationFrame & VSync vs Scroll-Driven Animations

Mechanical Verdict

rAF scroll loops sample scrollTop on the main thread, while Scroll-Driven Animations bind timelines to scroll on the compositor.

Try requestAnimationFrame & VSync LabTry Scroll-Driven Animations LabRead requestAnimationFrame & VSync DissectionRead Scroll-Driven Animations Dissection

Structured Comparison Matrix

DimensionrequestAnimationFrame & VSyncScroll-Driven Animations
Mental ModelrequestAnimationFrame schedules callbacks right before the browser paints the next VSync frame, matching display refresh rates.animation-timeline: scroll() and view() bind CSS and WAAPI animations directly to scroll progress on the Compositor Thread.
Maturity & DomainBaseline · Widely · Rendering Pipeline
Chrome 24+ · Firefox 23+ · Safari 6.1+
Experimental · Rendering Pipeline
Chrome 115+ · Firefox Behind flag (layout.css.scroll-driven-animations.enabled) · Safari 26+
Prerequisites
When Not to UseWhen not to use requestAnimationFrame: Do not use rAF for simple transform or opacity transitions; use CSS transitions, the Web Animations API, or Scroll-Driven Animations so they run off the main thread.When not to use Scroll-Driven Animations: Do not use them for critical navigation state or binary sticky-header triggers where IntersectionObserver or position: sticky suffices.

Engine Mechanics & Trade-Offs

requestAnimationFrame & VSyncBaseline · Widely

Compositor ticks on display VSync (60Hz/120Hz), triggers BeginMainFrame, drains rAF callbacks, and commits the frame.

Key Pitfalls: Frame-rate-dependent speed: Incrementing x += 2 per rAF callback runs twice as fast on a 120Hz screen as on a 60Hz screen; always use timestamp deltas. Multiple rAF loops: Spawning independent rAF loops per component fragments main-thread timing and invites Layout Thrashing.

Scroll-Driven AnimationsExperimental

Compositor Thread reads scroll offset directly and samples the linked animation timeline at 60/120fps without waking JS.

Key Pitfalls: Missing @supports guard: Setting opacity: 0 at 0% leaves elements permanently invisible in browsers lacking animation-timeline support. Animating width instead of scaleX(): Using width forces Layout on every scroll tick, forfeiting compositor offloading.

Seen in Architecture Autopsies