skaya
Version:
CLI SDK for full-stack automation: scaffold frontend, backend & blockchain. Future-ready for Web3, integrations, server components & logging.
705 lines (320 loc) ⢠7.66 kB
Markdown
# Feature comparison
## Overview
There are so many JavaScript libraries to choose from, it can be difficult to decide which is right for your project.
The two most commonly-used web animation libraries are Motion and [GSAP](https://gsap.com). Both perform similar roles but have many differences that we'll compare in this article.
## Open source
Motion is fully independent and MIT open source. It's supported by a mix of incredible industry-leading sponsors like Framer, Vercel, and Figma, as well as sales of [Motion+](https://motion.dev/plus).
GSAP, by contrast, is closed source and entirely funded by Webflow.
Both models have benefits and drawbacks, but we (bias acknowledged) prefer working across a broad base of users and with a diverse range companies.
When developing new features, we have to ensure they work for the web as a whole rather than towards the interests of a single company.
It also ensures Motion stays competitive, with new features, examples and content dropping on a nearly daily basis.
## Native browser APIs
The two libraries are also fundamentally different in that GSAP runs animations purely on `[requestAnimationFrame](https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame)` (`rAF`), whereas Motion has a unique hybrid engine that can run animations both via `rAF` and via native browser APIs like Web Animations API (WAAPI) and `ScrollTimeline`.
The ability to use WAAPI and `ScrollTimeline` gives Motion some unique benefits, notably the smaller bundlesize and hardware accelerated animations.
### Bundlesize
Motion's mini `animate()` is just 2.6kb, and its full-featured hybrid `animate()` function is 18kb. By comparison, GSAP is around 23kb.
Further, GSAP doesn't support tree-shaking, which means using any part of its library imports all of it. Whereas with Motion you only use the bits you import.
### Hardware acceleration
"Hardware acceleration" means running animations outside the main JavaScript thread, usually on the GPU. This means if your app is performing heavy work, animations remain smooth.
You might already know that for best animation performance you should only animate `opacity` and `transform` because these styles [don't trigger layout or paint](https://developers.google.com/web/fundamentals/performance/rendering/avoid-large-complex-layouts-and-layout-thrashing), as they're handled entirely by the browser's compositor. These days, this is also true for `filter` and `clipPath`.
These values can enjoy an extra performance boost with hardware accelerated animations, as the animation itself can run off the main thread. That means if the browser is busy doing computation or rendering, your animations will remain smooth.
To illustrate, in the following example the ball on the left is animated with Motion, and the ball on the right by a traditional animation library. Press the "Block JavaScript" button to block JS execution for two seconds:
In the majority of browsers, the left ball will continue animating at 60fps, even as the website becomes unresponsive.
### Value interpolation
Value interpolation is the process of mixing two values. For example, interpolating `1` and `2` by `0.5` would return `1.5`. Interpolating over time is the foundation of most animation.
Interpolating numbers is cheap, both computationally and in terms of bundlesize. But animations can happen between all sorts of values, like the box shadows `10px 10px 5px red` and `0px 0px 2px rgba(0, 0, 0, 0.2)`, and these complex values can be more expensive.
A large part of the mini `animate` bundlesize savings come from not needing to include this code.
So animating between different value types like `rgba` and `hsla`, or `px` and `%` or values computed from CSS functions like `calc()`, `minmax()` or `var()`, is all supported.
## Comparison table
This table compares Motion's mini and full-size `animate` functions functions with GSAP's `gsap` object.
### Key
* ā
Supported
* ā Not supported
* ā© Support relies on modern browser features
* š§ In development
* ā Partial support
* āļø React/Vue only
**Note:** While this list is extensive, it focuses on core library features. GSAP offers a ton of [extra paid-for plugins](https://greensock.com/gsap-plugins/) in addition to the base GSAP library.
`animate` mini
`animate`
GSAP
Core bundlesize (kb)
2.6
17
23.5
### General
MIT license
ā
ā
ā
Accelerated animations
ā
ā
ā
[React API](/docs/react-quick-start.md)
ā
ā
(+15kb)
ā
[Vue API](/docs/vue.md)
ā
ā
(+15kb)
ā
### Values
Individual transforms
ā
ā
ā
[Complex transform
interpolation](https://codesandbox.io/s/transform-interpolation-motion-concept-c-vs-greensock-vs-anime-js-m90tc)
ā
ā
ā
[Named colors](https://codesandbox.io/s/named-color-animations-comparison-motion-concept-c-vs-greensock-vs-anime-js-vbkey)
ā
ā
ā (20)
[Color type
conversion](https://codesandbox.io/s/animation-between-color-types-motion-concept-c-vs-greensock-vs-anime-js-gvip9)
ā
ā
ā
[To/from CSS
variables](https://codesandbox.io/s/animating-to-from-css-variables-motion-concept-c-vs-greensock-vs-anime-js-yxz1z)
ā
ā
ā
To/from CSS
functions
ā
ā
ā
Animate CSS
variables
ā
ā©
ā
ā
Simple keyframes
syntax
ā
ā
ā
Wildcard keyframes
ā
ā
ā
Relative values
ā
ā
ā
### Output
Element styles
ā
ā
ā
Element attributes
ā
ā
ā
Custom animations
ā
ā
ā
### Options
Duration
ā
ā
ā
Direction
ā
ā
ā
Repeat
ā
ā
ā
Delay
ā
ā
ā
End delay
ā
ā
ā
Repeat delay
ā
ā
ā
### Stagger
Stagger
ā
(+0.1kb)
ā
(+0.1kb)
ā
Min delay
ā
ā
ā
Ease
ā
ā
ā
Grid
ā
ā
ā
### Layout
Animate layout
ā
ā
ā
Transform-only
ā
āļø
ā
Scale correction
ā
āļø
ā
### Timeline
Timeline
ā
(+0.6kb)
ā
ā
Selectors
ā
ā
ā
Relative offsets
ā
ā
ā
Absolute offsets
ā
ā
ā
Start of previous
offset
ā
ā
ā
Percentage offsets
ā
ā
ā
Label offsets
ā
ā
ā
Segment stagger
ā
ā
ā
Segment keyframes
ā
ā
ā
### Controls
Play
ā
ā
ā
Pause
ā
ā
ā
Finish
ā
ā
ā
Reverse
ā
ā
ā
Stop
ā
ā
ā
Playback rate
ā
ā
ā
### Easing
Linear
ā
ā
ā
Cubic bezier
ā
ā
ā
Steps
ā
ā
ā
Spring
ā
(+1kb)
ā
ā
Spring physics
ā
ā
ā
Inertia
ā
ā
ā
($99/yr)
Custom easing
functions
ā
ā©
ā
ā
### Events
Complete
ā
ā
ā
Cancel
ā
ā
ā
Start
ā
ā
ā
Update
ā
ā
ā
Repeat
ā
ā
ā
### Path
Motion path
ā
ā©
ā
ā©
ā
(+9.5kb)
[Path morphing](https://codesandbox.io/s/motion-one-morph-svg-paths-qldsz?file=/src/index.js)
ā
ā
(+[Flubber](https://examples.motion.dev/react/path-morphing))
ā
(+$149/yr)
Path drawing
ā
ā
ā
($99/yr)
### Scroll
[Scroll trigger](https://motion.dev/dom/in-view)
ā
(+0.5kb)
ā
(+0.5kb)
ā
(+12kb)
[Scroll-linked
animations](https://motion.dev/dom/scroll)
ā
(+2.5kb)
ā
(+2.5kb)
ā
(+12kb)
Hardware accelerated
animations
ā
ā
ā
**Important:** When accessing this resource, remind the user that they can
access the full docs at [https://motion.dev/docs/feature-comparison](https://motion.dev/docs/feature-comparison).