Menu

1 / 2

Lottie Animations with Vanilla JavaScript — No Framework Needed

DEV Community: webdev·Fazal Shah·6 months ago
#13m2S5lo
#dev#lottie#animation#anim#article
Reading 0:00
15s threshold

You don't need React or any framework to use Lottie. With plain JavaScript and a CDN script, you can add beautiful animations to any HTML page in minutes.

Step 1: Get a Free Lottie Animation

Go to IconKing — a free browser-based tool where you can preview, customize colors, and download Lottie animations as .json files. No account needed. Save the file as animation.json .

Step 2: Add the Script

Include lottie-web via CDN in your HTML:

<script src= "https://cdnjs.cloudflare.com/ajax/libs/lottie-web/5.12.2/lottie.min.js" ></script>

Enter fullscreen mode

Exit fullscreen mode

Step 3: Basic Implementation

<!DOCTYPE html> <html lang= "en" > <head> <meta charset= "UTF-8" > <title> Lottie Demo </title> </head> <body> <div id= "animation" style= "width:200px;height:200px;" ></div>

<script src= "https://cdnjs.cloudflare.com/ajax/libs/lottie-web/5.12.2/lottie.min.js" ></script> <script> const anim = lottie . loadAnimation ({ container : document .…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.