Adding animations to your web application is one of the best approaches to improve the appearance and feel of your application.
Animations are moving objects that web designers/ developers use to capture users’ attention and direct them to take certain actions.
Writing code to add animations can be a lot of work. Luckily, you can use an animation library.
An animation library is a collection of pre-made animation files that designers can add to their websites.
Why use animation libraries?
- Saves time: The animation library will provide the barebones, giving you more time to focus on the functionality of your application.
- Customizable: Animation libraries typically offer boilerplate code that you can customize to suit your needs.
- Easy to attain a consistent design: If you have animations across different web pages, you can use one library to ensure that color blending and fonts are consistent.
- Provide a wide range of effects: Some animation libraries have many animations to choose from.
I have reviewed some of the best JavaScript animation libraries you can use as follows;
Anime.js
Anime.js is a lightweight JavaScript library with a powerful API. You can use this library with JavaScript objects, DOM attributes, SVG, and CSS properties.
Installation
npm install animejs --save
Usage
import anime from 'animejs/lib/anime.es.js';
Key Features:
- Easy to use: I found Anime.js easy to use, even for those with limited JavaScript knowledge, as it is well documented.
- Extensible: You can customize code blocks from this library to suit your needs. You can also create callbacks, timelines, and easing functions.
- Flexible: Anime.js is not only a JavaScript animation library; you can use it with SVG and CSS properties.
- Multi-browser support: Animations from Anime.js runs on various browsers such as Chrome, Safari, IE/Edge, Firefox, and Opera.
Anime.js is an open-source, free library.
Mo.js
Mo.js is a JavaScript motion graphics library. The library gives you total control over the animations through its declarative API.
Installation
npm install @mojs/core
or
yarn add @mojs/core
Usage
import mojs from '@mojs/core';
Key Features:
- Modular: Components in this library are split into small, reusable code blocks. While testing this library, I could add or do away with various components without rewriting the entire code.
- Simple: The declarative design of the API makes it easy to use this library and customize its components.
- Responsive: Mo.js is retina-ready, making it responsive to different screen sizes.
- Robust: This library has been extensively tested to ensure it works as expected.
Mo.js is a free, open-source library.
Popmotion
Popmotion is a simple animation library for creating delightful user interfaces. I found it easy to use this library with vanilla JavaScript and most JavaScript libraries and frameworks.
Installation
npm install popmotion
Usage
import { animate } from "popmotion"
Key Features:
- Powerful: Although the animate function is just 4.5kb, it supports spring, inertia, and keyframe animations for colors, numbers, and complex strings.
- TypeScript support: Popmotion is written in TypeScript, a superscript of JavaScript. Thus, you can use types if you are using TypeScript on your project.
- Customizable: Components from this library can be customized to fit your animation needs.
- Stable: All the components in Popmotion have been subjected to thorough testing.
Popmotion is free to use.
Theatre.js
Theatre.js is a library with a professional motion design toolset. With it, you can design cinematic scenes and delightful UI interactions.
To use Theatre.js with HTML and plain JavaScript, you can ad its CDN link to the head section of your HTML document.
Key Features:
- Works with several JavaScript frameworks and libraries: You can use Theatre.js with React Three Fiber and THREE.js.
- Customizable: This library has a cutting-edge sequence editor that helps you block sequences in seconds. You can also fine-tune every frame in your application using the graph editor.
- Extensible: Theatre.js has various extensions that add to its usability. You can use your tools or add extensions to this library.
Theatre.js is an open-source library.
ScrollReveal.js
ScrollReveal.js is a JavaScript library that allows you to animate elements as they scroll into the viewport.
Installation
npm install scrollreveal
Usage
const ScrollReveal = require('scrollreveal')
Key Features:
- Easy to use: Add
scrollreveal
class to the elements you want to animate, and you are ready to start using this library. - Extensible: You can add new elements or remove them from the components you get from this library.
- Flexible: You can set ScrollReveal.js to reveal elements on hover, click or scroll. The library also allows you to control the reveal’s easing, direction, and speed.
ScrollReveal.js is a paid library with packages starting from $30.
GreenSock GSAP
GreenSock GSAP is a JavaScript library for animating SVG
, UI
, React
, or Three.js
components. The library has everything you need to create fast and attractive animations.
Key Features:
- High compatibility: You can use GSAP with Canvas, CSS, HTML, SVG, and JavaScript libraries and frameworks such as Angular, React, Vue, and jQuery.
- Expandable: GSAP’s modular architecture allows you to customize components to suit your animation needs.
- Flexible: GSAP has no predefined list of things you can animate. You can animate any numeric property of an object.
- Robust: With GSAP, you can animate arrays, beziers, CSS properties, colors, and more. This library also allows you to build sequences, repeat, yoyo, and define callbacks.
GreenSock Animation Platform (GSAP) has a free package, while paid one starts from £88.
ProgressBar.js
ProgressBar.js is an animation library for creating responsive and stylish progress bars for the web.
Installation
Using bower
bower install progressbar.js
Using npm
npm install progressbar.js
Key Features:
- Various inbuilt shapes: ProgressBar.js has three built-in shapes, a SemiCircle, Circle, and Line. You can also create a custom shape using this library.
- Responsive: The progress bars from this library work perfectly on different screen sizes.
- Customizable: You can customize your components’ colors, font size, and font style.
ProgressBar.js is an open-source library.
AnisJS
AniJS is a UI interaction library that provides a quick and easy way to develop and prototype UIs. This library is 9.0kb after zipping.
Installation
bower install anijs --save
Usage
<script src="anijs-min.js"></script>
Key Features:
- Simple to use: To use this library, add AnisJS class to an element you need to animate.
- Extensible: You can customize components from AnisJS to suit your needs.
- Flexible: You can use AnisJS with JavaScript objects, SVG attributes, CSS properties, and DOM elements.
- Compatible with major browsers: You can AnisJS with Chrome, Firefox, Safari, and Edge.
AnisJS is an open-source library that is free to use.
Three.js
Three.js is a general-purpose 3D library. The library uses a WebGL renderer but also supports SVG and CSS3D renderers as add-ons.
Installation
npm install --save three
Usage
import * as THREE from 'three';
Key Features:
- Ease of use: Three.js has a well-documented API, making it easy to set up and use.
- Powerful: You can create complex 3D scenes using this library. Three.js also supports various features, such as animations, materials, and lighting.
- Flexible: You can create different 3D animations ranging from games, visualizations to simulations.
- Compatible with various frameworks and libraries: You can use the Three.js library with React Three Fiber, Egret, Aframe, PlayCanvas and Babylon.js.
Three.js is an open-source JavaScript library.
Vivus.js
vivus.js is a lightweight JavaScript library for animating SVGs. When you animate SVGs using this library, they appear as if they have been drawn.
Installation
npm install vivus
or
bower install vivus
Key Features:
- Various animation types: Vivus.js allows you to create Delayed, OnebyOne, and Sync animations. Delayed is the default animation type in this library.
- Allows custom scripts: Instead of using the animation types available in this library, you can create custom scripts to animate your SVG files.
- No dependencies: You can use this library on most web projects as it is dependency-free.
Vivus.js is a free library.
Tilt.js
Tilt.js is a small JavaScript library that allows developers to create 3D tilt effects on the DOM. You can use Tilt.js with vanilla JavaScript or libraries and frameworks like React, Preact, Angular, and Polymer.
Installation
npm install --save tilt.js
Or
yarn add tilt.js
Usage
Add this script just before the closing </body> tag.
<script src="tilt.jquery.js"></script>
Key Features:
- Easy to use: Add data-tilt attribute to the element you want to target to start using Tilt.js.
- Customizable: You can customize components from Tilt.js to suit your needs.
- Responsive: The components from this library can be used on devices with varying screen sizes.
- Accessible: Tilt.js is built with accessibility in mind and supports screen readers and keyboard navigation.
Barba.js
Barba.js is a small library for creating fluid and smooth transitions between pages on a website. This library’s minified, compressed version is 7kb and comes in handy in minimizing browser requests and reducing the delay between different web pages.
Installation
npm install @barba/core
or
yarn add @barba/core
Usage
import barba from '@barba/core';
Key Features:
- Written in TypeScript: You can catch code errors early as TypeScript allows you to define types in your code.
- Smart transitions: Barba.js allows you to define the rules and determines the right transitions for your application.
- Various plugins: You can improve the functionality of Barba.js through plugins such as barbarouter and barbaprefetch.
BarbaJS is a free-to-use library under an MIT license.
Splide
Splide is a lightweight slider/carousel written in TypeScript. This library allows you to create different slide types by changing options such as thumbnails, multiple slides, vertical direction, and nested sliders.
Installation
npm install @splidejs/splide
Key Features:
- Extensible: You can add additional components to your app through the extension feature.
- Flexible: You can use Splide to create various slider types, such as video sliders, text sliders, and image sliders. You can also create nested sliders.
- Dependency-free: You can use Splide with any build tool or framework, as it doesn’t depend on other libraries.
Splide has a free package for personal use. If you intend to use this library commercially, you get a license for premium packages that start from $10.
Conclusion
You can use the animation libraries above to turn static layouts into vibrant ones. The choice of the animation library will depend on what you want to achieve and the ease of use. Sometimes, you may use multiple animation libraries across different application pages.
If you love JavaScript libraries, you can check out our article on the best React animation libraries you can use.