Lottie Animation - How to Add One to Any Website

Lottie animations look incredible on websites - smooth, lightweight, scalable to any size. But adding one usually means installing lottie-web, writing initialization code, managing playback states, and debugging why the animation won't loop. For a 20KB JSON file, that's a lot of overhead.
There's a simpler way. OneType Transforms lets you add a Lottie animation to any website with one HTML attribute. Point it to a JSON file, set your playback options, done. No npm, no build tools, no JavaScript to write.
What is a Lottie animation?
Lottie is an animation format originally created by Airbnb. Designers build animations in After Effects, export them as small JSON files using the Bodymovin plugin, and those files play back on the web as crisp SVG animations. A complex animation that would be 2MB as a GIF might be just 30KB as a Lottie file.
Unlike videos or GIFs, Lottie animations are vector-based. They scale to any size without pixelating, load fast, and look sharp on retina displays. You can find thousands of free Lottie files on LottieFiles - icons, illustrations, loading spinners, hero animations, and more.
How to add a Lottie animation to your website
Two steps. First, add the OneType Transforms script tag to your site. Then drop in the Lottie HTML wherever you want the animation.
Step 1: Add the script tag
Paste this in your site's or before the closing tag:
<script src="https://cdn.transforms.onetype.ai/bundle/{YOUR-TOKEN}.js"></script>
Lottie is a premium transform, so you need a [paid plan (their pricing)](https://transforms.onetype.ai/pricing) to use it. Sign up at transforms.onetype.ai/get-started to get your token.
Step 2: Add the Lottie element
Add a div with the ot="lottie" attribute and point it to any Lottie JSON URL:
<div ot="lottie" ot-path="https://assets2.lottiefiles.com/packages/lf20_UJNc2t.json" style="width: 200px; height: 200px;"></div>
That's it. The animation loads, renders as SVG, and loops automatically. No JavaScript initialization, no library imports - the script handles everything.
Where to find Lottie JSON files
The biggest source is LottieFiles - thousands of free and premium animations. Browse by category, preview them, and copy the JSON URL directly. Other options include IconScout, LottieFlow, and creating your own in After Effects with the Bodymovin plugin.
When you find an animation you like, you just need the direct URL to the .json file. Paste that URL into the ot-path attribute and the animation plays on your site.
How to control Lottie playback
By default, the animation autoplays and loops. You can change that with a few HTML attributes.
- ot-loop="false" - play once and stop
- ot-autoplay="false" - don't start until triggered
- ot-speed="0.5" - half speed (or 2 for double)
- ot-direction="-1" - play in reverse
Example - a slow, non-looping animation:
<div ot="lottie" ot-path="your-animation.json" ot-loop="false" ot-speed="0.5" style="width: 300px; height: 300px;"></div>
How to trigger Lottie animations on scroll, hover, or click
This is where it gets interesting. Instead of autoplaying, you can trigger animations based on user interaction using the ot-trigger attribute.
Scroll trigger
The animation plays when it scrolls into view. Good for illustrations and icons that should animate as the user scrolls down the page.
<div ot="lottie" ot-path="your-animation.json" ot-trigger="scroll" ot-loop="false" style="width: 200px; height: 200px;"></div>
With ot-loop="false", it plays once when visible and stops. Without it, the animation pauses when scrolled out of view and resumes when scrolled back in.
Hover trigger
The animation starts when the user hovers over it. Two modes available:
- ot-hover-action="play" - plays on hover, pauses on mouse leave
- ot-hover-action="reverse" - plays forward on hover, plays backward on mouse leave
<div ot="lottie" ot-path="your-animation.json" ot-trigger="hover" ot-hover-action="reverse" style="width: 200px; height: 200px;"></div>
The reverse mode is great for interactive icons - the animation unfolds on hover and folds back when the mouse leaves.
Click trigger
Users click to control playback. Two modes:
- ot-click-action="toggle" - click to play, click again to pause
- ot-click-action="restart" - each click replays from the beginning
Lottie renderers: SVG vs Canvas
By default, Lottie renders as SVG - sharp at any size, accessible, and lightweight. For most animations, SVG is the right choice.
If you have a performance-heavy animation with lots of layers, you can switch to Canvas rendering:
<div ot="lottie" ot-path="complex-animation.json" ot-renderer="canvas" style="width: 400px; height: 400px;"></div>
Canvas trades some sharpness for better performance on complex scenes. Stick with SVG unless you notice frame drops.
All Lottie configuration options
Here's every attribute you can use to customize the Lottie transform:
- ot-path - URL to the Lottie JSON file (required)
- ot-loop - true/false, whether to loop (default: true)
- ot-autoplay - true/false, start automatically (default: true)
- ot-speed - playback speed multiplier (default: 1)
- ot-direction - 1 for forward, -1 for reverse (default: 1)
- ot-renderer - svg, canvas, or html (default: svg)
- ot-trigger - none, scroll, hover, or click (default: none)
- ot-hover-action - play or reverse (default: play)
- ot-click-action - toggle or restart (default: toggle)
Adding Lottie animations on different platforms
The setup works the same everywhere - add the script tag, then use the ot="lottie" attribute. The only difference is where each platform lets you paste the code.
- WordPress - add the script via the WPCode plugin, then use Custom HTML blocks for the Lottie element. Full WordPress guide
- Elementor - add the script via Elementor Custom Code (Pro) or WPCode (Free), then use the HTML widget. Full Elementor guide
- Webflow - paste the script in Site Settings > Custom Code > Footer, then use an Embed element
- Shopify - add the script to theme.liquid before , then use Custom Liquid sections
- Squarespace - add the script in Code Injection > Header, then use Code Blocks
- Framer - add the script in Settings > Custom Code > End of head, then use an Embed component
Why use OneType for Lottie instead of lottie-web directly?
You can absolutely use lottie-web yourself. It's open source and well documented. But it requires writing JavaScript - initializing the player, setting options, managing playback, handling triggers.
OneType wraps all of that into HTML attributes. You get the same lottie-web library under the hood, but configured through markup instead of code. Scroll triggers, hover interactions, click-to-play - all without touching JavaScript. For designers and non-coders, that's the difference between spending 10 minutes and spending an hour.
Get started
Lottie is a premium transform available on the paid plan (their pricing). Sign up at transforms.onetype.ai/get-started, grab your script tag, and start adding animations to your site.
