GSAP Motion

GSAP Reduced Motion Done Right: Preferences, Fallbacks and OS Testing

GSAP reduced motion means reading the prefers-reduced-motion setting before any timeline runs and swapping animation for the finished, usable state. In my builds I use gsap.matchMedia() to register motion-safe and reduced branches, gsap.set() to land elements at their final values, and a CSS fallback for the no-JavaScript case. I then verify with real macOS and Windows accessibility settings, not only DevTools emulation.

By Saif Al Jahanwebdev-saif.com

What GSAP reduced motion actually means

Reduced motion is a user preference that should be honoured, not a bug to work around. When someone enables it in the operating system, the browser exposes prefers-reduced-motion: reduce through CSS and window.matchMedia(). The practical meaning for a GSAP build is that decorative and large-scale movement — reveals, parallax, pinning, looping marquees, scroll-scrubbed timelines — must not run. The content and the flow still have to work: a card that animates in must be present and readable without the animation, and a tab panel must still change. I treat reduced motion as a second, fully supported rendering path rather than a flag that skips a few lines. That distinction matters because most broken implementations remove the animation and accidentally remove the content with it. WCAG 2.3.3 covers animation from interactions; the accessible outcome is that non-essential motion is gone and nothing is lost.

  • Non-essential movement off: reveals, parallax, pinning, loops
  • Functional state changes kept, with an instant or minimal transition
  • Content present and readable even without JavaScript
  • The preference is per visitor and can change mid-session
  • Treat it as a supported rendering branch, not a bug flag

Read the preference with matchMedia, and listen for changes

The browser gives you two things: a CSS media query and a MediaQueryList from window.matchMedia("(prefers-reduced-motion: reduce)"). The matches boolean is the value to branch on at startup. Do not assume that "not reduce" means "no-preference": some environments leave the feature undefined, so write the motion-safe path as the default and only the reduce branch as the override. A visitor can toggle the setting while your page is open, so attach a change listener with addEventListener("change", handler), using addListener only as a legacy fallback, and re-run your setup. That listener is what makes the page respond without a reload. I also check the media query in CSS for cases JavaScript never reaches, such as a hero that should never translate. The setting reports an OS-level preference, not a per-site choice, so I never try to override it with a cookie.

  • window.matchMedia("(prefers-reduced-motion: reduce)").matches
  • addEventListener("change", handler) for live OS toggles
  • addListener only as the legacy fallback
  • Motion-safe is the default path; reduce is the override
  • Keep a CSS @media rule for markup JavaScript never touches

Use gsap.matchMedia() to scope and revert animations

Since GSAP 3.11, gsap.matchMedia() is the cleanest way to keep animated and reduced branches apart. You register named conditions — for example reduce: "(prefers-reduced-motion: reduce)" and motion: "(prefers-reduced-motion: no-preference)" — then call mm.add("motion", () => { ... }) for the animated branch and mm.add("reduce", () => { ... }) for the static one. GSAP evaluates the queries and, when a condition stops matching, automatically reverts everything created inside its callback: timelines, tweens and ScrollTriggers included. You can also return your own cleanup function from the callback for anything GSAP cannot track. I prefer this to a single manual if check because it survives an OS toggle and because mm.revert() gives me one teardown call on component unmount or SPA route changes. It replaces the older ScrollTrigger.matchMedia() pattern.

  • Register conditions once: reduce and motion
  • mm.add("motion", ...) holds all tweens and ScrollTriggers
  • mm.add("reduce", ...) sets the final state instantly
  • Return a custom cleanup function for untracked listeners
  • mm.revert() on unmount or route change

Graceful fallbacks: land on the final state, not an empty one

The most common reduced-motion bug is invisible content. A theme puts opacity: 0 on reveal elements in CSS, then relies on a GSAP from() tween to bring them in. When the tween is skipped, the elements stay transparent. My rule is that the static markup must be complete and visible on its own; animation is an enhancement layered on top. In the reduce branch I call gsap.set() with the same end values the animation would reach — opacity: 1, y: 0, clearProps where needed — so the design still reads correctly. For a reveal on scroll, IntersectionObserver can add a class instead of running a timeline, and that class changes nothing affecting readability. In CSS I add @media (prefers-reduced-motion: reduce) to strip transitions and transforms from elements I do not control in JavaScript.

  • Never hide content in CSS and depend on JS to reveal it
  • gsap.set() to final values, not gsap.to() from zero
  • IntersectionObserver plus a class for non-animated reveals
  • CSS @media fallback for third-party markup
  • Keep focus order and keyboard access identical in both branches

ScrollTrigger, loops and pinning need their own branch

Scroll-driven work is where reduced motion is easiest to get wrong. A scrubbed timeline ties visual state to scroll position, which can cause discomfort even at low speed; a pinned section takes over the scroll experience; a looping marquee never stops. In my reduce branch none of those are created at all. Instead I render the section at its natural end state and let the page scroll normally. Where a scroll-linked value carries information — a progress bar or a step indicator — I keep the value updating but remove the smoothing, so it snaps to the current position instead of easing toward it. After switching branches I call ScrollTrigger.refresh() once so measurements match the new layout. Looping repeat: -1 tweens for decorative accents are simply never registered under reduce.

  • Skip scrub, pin and parallax entirely under reduce
  • Render the scroll-linked section in its final state
  • Keep informational progress, drop the easing
  • ScrollTrigger.refresh() after a branch switch
  • No repeat: -1 decorative loops in the reduced branch

How I wire it into a WordPress or PHP build

I am Saif Al Jahan, a WordPress and PHP developer based in Mymensingh, Bangladesh, and I keep motion decisions in one place so a theme update cannot silently break them. GSAP is enqueued in the footer with wp_enqueue_script() and a versioned handle; a small inline config object passes the animation targets, never the preference itself, because the browser is the source of truth. The theme registers gsap.matchMedia() once on DOM ready, and each template only declares which elements are animated. I document the two branches in the theme README alongside the selectors they touch. Page-builder markup is the usual problem: Elementor-style inline animation settings often run their own JavaScript and ignore the OS preference, so I disable those effects on builds where I own the motion and keep a single GSAP path.

  • wp_enqueue_script() for GSAP in the footer with a versioned handle
  • The browser reads the preference; PHP never hard-codes it
  • One gsap.matchMedia() registration shared by templates
  • Document animated selectors in the theme README
  • Disable competing page-builder effects on the same elements

Test with OS settings, then automate the regression

Media-query emulation is a useful first check and a poor final one. I do the first pass in Chrome DevTools under Rendering → Emulate CSS media feature prefers-reduced-motion: reduce, then repeat on real settings: macOS System Settings → Accessibility → Display → Reduce motion; Windows Settings → Accessibility → Visual effects → Animation effects; iOS Settings → Accessibility → Motion → Reduce Motion; Android Settings → Accessibility → Remove animations. On each I reload, toggle the setting with the page open, and confirm nothing is invisible, no loop is running and scroll behaves normally. For regression coverage, Playwright page.emulateMedia({ reducedMotion: "reduce" }) gives a repeatable check in CI, with a second run at "no-preference". I also watch Core Web Vitals: a correct reduce branch often improves INP because it removes main-thread animation work.

  • Chrome DevTools Rendering panel for a quick first pass
  • MacOS, Windows, iOS and Android accessibility settings for the real check
  • Toggle the OS setting live, not only on page load
  • Playwright emulateMedia({ reducedMotion: "reduce" }) in CI
  • Re-check INP and CLS after shipping the reduce branch

Frequently asked questions

Does prefers-reduced-motion mean I must remove every GSAP animation?

No. It means removing non-essential movement, not functionality. A card reveal, parallax layer or looping marquee should not animate, but a menu opening, a tab switch or a form error still needs a clear state change. In the reduced branch I set elements to their final values instantly with gsap.set() and keep the same accessible markup. A minimal opacity change is acceptable when it communicates cause and effect; large translations, scrubbing and pinning are not.

What is gsap.matchMedia() and why use it over a manual if statement?

gsap.matchMedia() is GSAP query-aware context. You define conditions, add animations inside each one, and GSAP reverts everything created there when the query stops matching. A manual if check runs once and leaves stale tweens and ScrollTriggers behind if the visitor changes the OS setting. With matchMedia I get automatic cleanup, an explicit reduce branch and one mm.revert() call for unmounts or route changes.

How do I test reduced motion without changing my operating system settings?

For a quick check, open Chrome DevTools, go to the Rendering panel and set Emulate CSS media feature prefers-reduced-motion to reduce. For automated checks, Playwright page.emulateMedia({ reducedMotion: "reduce" }) does the same in CI. Both are emulations, so I still confirm once on real macOS, Windows, iOS and Android accessibility settings before shipping, especially where native scrolling or third-party embeds are involved.

Why is my content invisible when reduced motion is enabled?

Because the animation is the only thing that reveals it. A common pattern is opacity: 0 in CSS plus a GSAP from() tween; skip the tween and the element stays transparent. Fix it by making the static markup complete and visible, then animating as an enhancement. In the reduce branch call gsap.set() with the end values, and add a CSS @media (prefers-reduced-motion: reduce) rule for anything JavaScript does not own.

Do I need to change ScrollTrigger for visitors who prefer reduced motion?

Yes. Scrubbed timelines, pinning and parallax are the effects reduced-motion users are asking you to drop. Register them only in the motion-safe branch of gsap.matchMedia() and render the section at its final state otherwise. If a scroll-linked indicator carries meaning, keep it updating but remove the smoothing, then call ScrollTrigger.refresh() after the branch changes so measurements match the new layout.

Written by Saif Al Jahan, webdev-saif.com · Mymensingh, Bangladesh. Last updated .