Web Animations API
A native browser JavaScript API for creating and controlling animations without CSS or animation libraries
animate()`, that lets developers create, control, and sequence animations programmatically with the same rendering engine used by CSS animations and transitions.
Definition
The Web Animations API (WAAPI) is a native browser JavaScript interface, most commonly accessed via `Element.animate()`, that lets developers create, control, and sequence animations programmatically with the same rendering engine used by CSS animations and transitions.
Overview
Before the Web Animations API, JavaScript-driven animation on the web meant either manually manipulating styles on every frame using `requestAnimationFrame` — powerful but requiring the developer to hand-write easing, timing, and interpolation logic — or defining the animation declaratively in CSS and controlling it indirectly through class toggling, which limits how precisely JavaScript can pause, reverse, or query an animation's current state mid-flight. The Web Animations API was designed to unify these approaches: it exposes CSS's underlying animation engine directly to JavaScript, so animations get the same off-main-thread performance characteristics as CSS animations, while still being fully controllable and inspectable through code. The core entry point is `element.animate(keyframes, options)`, which takes an array of keyframe objects describing style values at different points and an options object specifying duration, easing, iteration count, and fill mode, and returns an `Animation` object. That returned object exposes methods like `play()`, `pause()`, `reverse()`, and `cancel()`, and properties like `currentTime` and `playbackRate`, giving JavaScript the same level of control over a WAAPI animation that it would have over a `<video>` element, including the ability to scrub to a specific point or bind playback rate to user input like scroll position. Because the specification standardizes the same underlying animation model that CSS `@keyframes` and transitions already use in browsers, WAAPI animations composite and run efficiently, and CSS animations can, in supporting browsers, actually be retrieved and manipulated as `Animation` objects via `Element.getAnimations()`, bridging the declarative and imperative animation worlds. This standardization is also why several JavaScript animation libraries, including GSAP and Motion (formerly Framer Motion), have added WAAPI as an optional rendering backend, using the native browser primitive instead of manual `requestAnimationFrame` loops where supported, for better performance and lower JavaScript main-thread cost.
Specification
- element.animate(keyframes, options) as the primary JavaScript entry point
- Returns a controllable Animation object with play(), pause(), reverse(), cancel()
- currentTime and playbackRate properties for precise scrubbing and rate control
- Shares the same underlying animation engine as CSS animations and transitions
- Element.getAnimations() retrieves and manipulates CSS-driven animations as JS objects
- Runs with performance characteristics similar to native CSS animations
- No external library required — built into all modern browsers
- Used as an optional performance backend by libraries like GSAP and Motion
Use Cases
Alternatives
History
The Web Animations API (WAAPI) provides a single, scriptable model and timeline for animation on the web, unifying the behavior that previously lived in separate specifications — CSS Animations, CSS Transitions, and SVG animation — under one common engine. The effort grew out of a request from the Internet Explorer team for a consolidated animations API, after Safari had introduced CSS Animations and Transitions; Mozilla and Google developers then collaborated on "one animation spec to rule them all." Standardized by the W3C as Web Animations, it exposes methods such as element.animate() and gives developers programmatic control to play, pause, reverse, and sequence animations, and to coordinate with animations defined declaratively in CSS.
Sources
- W3C — Web Animations Level 1 specification · as of 2026-07-17
- MDN Web Docs — Web Animations API · as of 2026-07-17