How do I add a Lottie animation to an HTML website?
Short answer
The simplest way is the dotLottie web component: load @lottiefiles/dotlottie-wc from a CDN and add a <dotlottie-wc> tag with src, autoplay and loop attributes. If you prefer full control, load lottie-web and call lottie.loadAnimation() on a container div.
Core Takeaway
Web component: <dotlottie-wc src="..." autoplay loop>
Script option: lottie-web with lottie.loadAnimation()
Give the container a fixed size to avoid layout shift
Host the JSON or .lottie file on your own domain or a CDN
Respect prefers-reduced-motion for looping decoration
Webflow has a native Lottie element. On WordPress, use a Lottie block plugin or paste the web component into a custom HTML block. Either way, upload the file to your media library or a CDN.
Good practice
Set a width and height, lazy-load animations below the fold, and pause or skip looping decoration when the user has prefers-reduced-motion set. If the file is served from another domain, that domain must allow cross-origin requests.
Frequently asked questions
Can I use Lottie without JavaScript?
No. A player script is needed to draw the animation. Export a GIF or video if you cannot run scripts.
Why does my Lottie not load locally?
Opening the HTML file directly blocks loading JSON. Serve the folder with a local server.
Is lottie-player still maintained?
LottieFiles now points developers to its dotLottie players. Check the package page before starting a new project with the older lottie-player.
How do I make a Lottie play on hover?
Set autoplay off and call play() on mouseenter and pause() or stop() on mouseleave.