Repository navigation
Description
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@keyframesanimation withinfiniteiteration, or setsscroll-behavior: smooth; - a
<video autoplay>that loops or has nocontrols; <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 (
transitionalone), a single non-looping entrance animation, animated GIFs (left toperf/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, andsite.scriptskeeps script bodies, but external stylesheets are only size-checked (HEAD, with a GET fallback for size) andsite.resourceSizes.cssentries carry no content. Most sites keep their@mediaqueries 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,@supportsand@keyframeswith 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 noprefers-reduced-motionanywhere, produces a warning naming AOS and the page - Fixture: a page whose inline
<style>runsanimation: spin 2s infiniteand 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
transitionrules 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
feat(rules): add a11y/reduced-motion rule #711
fix(rules): update a11y counts, invariance fixture and engine golden …
feat(rules): add a11y/reduced-motion rule #711
fix(rules): update a11y counts, invariance fixture and engine golden …
fix(rules): strip the stylesheet query string from a11y/reduced-motio…
feat(rules): add a11y/reduced-motion rule #711
fix(rules): update a11y counts, invariance fixture and engine golden …
fix(rules): strip the stylesheet query string from a11y/reduced-motio…
fix(rules): strip URL credentials and fragment from a11y/reduced-moti…
feat(rules): add a11y/reduced-motion rule #711
fix(rules): update a11y counts, invariance fixture and engine golden …
38 remaining items
feat(rules): add a11y/reduced-motion rule #711
fix(rules): update a11y counts, invariance fixture and engine golden …
fix(rules): strip the stylesheet query string from a11y/reduced-motio…
fix(rules): strip URL credentials and fragment from a11y/reduced-moti…
test(audit-engine): add a11y/reduced-motion to the per-rule golden, h…
fix(rules): stop a11y/reduced-motion false positives from unused CSS,…
fix(rules): ignore font-only stylesheet hosts and unused smooth-scrol…
feat(rules): add a11y/reduced-motion rule #711
fix(rules): update a11y counts, invariance fixture and engine golden …
fix(rules): strip the stylesheet query string from a11y/reduced-motio…
fix(rules): strip URL credentials and fragment from a11y/reduced-moti…
test(audit-engine): add a11y/reduced-motion to the per-rule golden, h…
fix(rules): stop a11y/reduced-motion false positives from unused CSS,…
fix(rules): ignore font-only stylesheet hosts and unused smooth-scrol…