Imports V4

The Anime.js v4 API is designed with an ESM-first approach with excellent tree shaking support, while also providing a CJS version and UMD/ESM bundles.

ES Modules

Import Anime.js using ES Modules syntax with the import statement:

import {
  animate,
  createTimeline,
  createTimer,
  // ...other methods
} from 'animejs';

Or import directly from 'dist/modules/index.js';

CommonJS Modules

Import Anime.js using CommonJS syntax with the require function:

const {
  animate,
  createTimeline,
  createTimer,
  // ...other methods
} = require('animejs');

Or import directly from 'dist/modules/index.cjs';

Global UMD bundle (Universal Module Definition)

The bundled UMD version of Anime.js can be used globally using a script tag:

<script src="dist/bundles/anime.umd.min.js"></script>
<script>
  const {
    animate,
    createTimeline,
    createTimer,
    // ...other methods
  } = anime;
</script>

Bundled ES Modules

A bundled and minified ESM version is also available for easy embedding:

<script type="module">
  import {
    animate,
    createTimeline,
    createTimer,
    // ...other methods
  } from 'dist/bundles/anime.esm.min.js';
</script>