Skip to content

New rule: a11y/reduced-motion - motion with no prefers-reduced-motion handling #711

Description

@nc9

Problem

Parallax hero sections, scroll-triggered fade-ins, auto-advancing carousels and looping background video can make people with vestibular disorders dizzy or nauseous. Every major OS has a "reduce motion" setting, and browsers expose it as @media (prefers-reduced-motion: reduce). A site that animates without ever reading that query ignores the setting completely.

squirrel does not check for this. perf/animated-content only suggests turning large GIFs into video, the shared decorative-video helper and a11y/video-captions only decide whether a muted autoplay video needs captions, and perf/carousel-hidden-eager looks at carousel image loading. No rule asks whether motion can be turned off.

Proposal

New rule a11y/reduced-motion. It reads markup, inline <style> blocks and scripts, so it runs in the CLI and in HTTP-only audits.

Motion signals on a page (any one is enough):

  • an inline <style> or first-party stylesheet that applies a @keyframes animation with infinite iteration, or sets scroll-behavior: smooth;
  • a <video autoplay> that loops or has no controls;
  • <marquee>;
  • a scroll or motion library, from markup or script URLs: AOS (data-aos), GSAP ScrollTrigger, Lottie players (lottie-player, dotlottie-player), animate.css / WOW.js classes, parallax (data-parallax, Rellax, Jarallax), Locomotive Scroll / Lenis;
  • a carousel set to auto-advance (data-autoplay, Swiper/Slick/Splide autoplay options).

Reduced-motion handling counts if prefers-reduced-motion appears in any CSS or script the audit read for that page: an @media query in a <style> block or stylesheet, a matchMedia("(prefers-reduced-motion...)") call, or a <source media="(prefers-reduced-motion...)">.

  • Warn: the page has a motion signal, the audit read all of its first-party CSS, and none of it handles reduced motion.
  • Info (unverified): the same, but some referenced stylesheets were not read, so the handling may live there. Say so in the message.
  • One finding per motion source across the site (e.g. "AOS scroll animations on 42 pages"), with the pages and the signal that triggered it, since motion usually comes from a shared template.
  • Not reported: hover and focus transitions (transition alone), a single non-looping entrance animation, animated GIFs (left to perf/animated-content), and pages where motion only runs inside @media (prefers-reduced-motion: no-preference).

Notes

  • The data gap: rules can read inline <style> today, and site.scripts keeps script bodies, but external stylesheets are only size-checked (HEAD, with a GET fallback for size) and site.resourceSizes.css entries carry no content. Most sites keep their @media queries in external CSS, so without stylesheet bodies the rule would warn on sites that handle reduced motion correctly. This needs a bounded fetch of first-party stylesheet bodies (per-file and per-audit byte caps), or a small per-stylesheet summary computed at fetch time (mentionsReducedMotion, hasInfiniteAnimation, hasSmoothScroll) so the bodies are not held in memory. Until that exists, the rule may only emit the unverified info result.
  • CSS reading: reuse the string- and comment-aware CSS walker in content/hidden-text.ts (it already descends @media, @supports and @keyframes with size and rule budgets) rather than writing a third parser. Budget by bytes and rules on hostile input.
  • False-positive risk: medium. Library defaults matter: some respect the OS setting on their own, and the rule should know which before warning. Script-driven motion with handling inside a bundle the audit did not fetch is the main remaining source of noise, which is why missing data downgrades to info.
  • WCAG: 2.3.3 Animation from Interactions (AAA) and 2.2.2 Pause, Stop, Hide (A). Technique C39 uses prefers-reduced-motion. A static check cannot prove 2.2.2 (a pause button may exist), so the rule reports missing reduced-motion handling, not a WCAG failure.
  • Cost: markup and CSS scanning only, plus the stylesheet body fetch above.

Acceptance Criteria

  • Fixture: a page with <div data-aos="fade-up"> and AOS loaded, and no prefers-reduced-motion anywhere, produces a warning naming AOS and the page
  • Fixture: a page whose inline <style> runs animation: spin 2s infinite and has no reduced-motion query produces a warning; adding @media (prefers-reduced-motion: reduce) { * { animation: none } } to the same page clears it
  • Fixture: a page with <video autoplay loop muted> and handling only in a first-party external stylesheet produces no warning once that stylesheet's body is read
  • Fixture: a page whose <marquee> or autoplay carousel is the only motion produces a warning
  • Fixture: a page with only hover transition rules produces no finding
  • When a referenced stylesheet was not read (cap, error or third-party), the result is info and the message says the check was partial, never a warning
  • A matchMedia("(prefers-reduced-motion: reduce)") call in an inline or fetched script counts as handling
  • The same motion source on 20 template pages produces one finding listing those pages, not 20 findings
  • Stylesheet reading is bounded: a 5 MB stylesheet or one with 100,000 rules does not exceed the per-file budget or slow the audit noticeably
  • The rule has a docs page under docs/rules/a11y/ citing WCAG 2.3.3 and 2.2.2

Activity

  1. added
    enhancement
    size: L
    rules
    on Oct 12, 2026
  2. added theissue type on Oct 28, 2026
  3. 38 remaining items

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementrulessize: L

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions