Animations

Lottie Animation in WordPress - How to Add One Without a Plugin

Stefan Pakic4 min read

A Lottie animation playing on a web page

Most WordPress Lottie plugins add bulk - extra database queries, settings pages, shortcode parsers, and JavaScript you don't need. All you want is a JSON animation playing on a page. There's a lighter way to do it.

OneType Transforms loads Lottie animations through a single CDN script and HTML attributes. No plugin to install, no settings to configure, no shortcodes to memorize. Just a script tag and a div.

How to add a Lottie animation to WordPress

Step 1: Add the script tag

The easiest way is with the free WPCode plugin (formerly Insert Headers and Footers). It has 2 million installs and takes 30 seconds to set up.

  1. Go to Plugins > Add New, search "WPCode", install and activate
  2. Go to Code Snippets > Header & Footer
  3. Paste the script tag in the Header section:
<script src="https://cdn.transforms.onetype.ai/bundle/{YOUR-TOKEN}.js"></script>

Lottie is a premium transform - you need a paid plan (their pricing). Get your token at transforms.onetype.ai/get-started.

Click Save Changes. The script now loads on every page of your WordPress site.

Alternative for developers: add the script via your child theme's functions.php using wp_enqueue_scripts. But WPCode is simpler and survives theme updates.

Step 2: Add the Lottie animation to a page

With Gutenberg (Block Editor):

  1. Edit the page where you want the animation
  2. Click the + button and search for "Custom HTML"
  3. Add the Custom HTML block and paste:
<div ot="lottie" ot-path="https://assets2.lottiefiles.com/packages/lf20_UJNc2t.json" style="width: 200px; height: 200px;"></div>

Replace the URL with any Lottie JSON file. Browse LottieFiles for thousands of free animations.

With Classic Editor: switch to the Text tab, paste the same HTML, and switch back to Visual. The HTML stays intact.

Step 3: Publish and check

Save the page and view it on the front end. The Lottie animation should be playing. It won't show in the Gutenberg editor preview - that's normal. The animation activates on the live page.

WordPress.com vs WordPress.org

If you're on WordPress.org (self-hosted), everything above works out of the box. Install WPCode, add the script, use Custom HTML blocks.

If you're on WordPress.com, it depends on your plan:

  • Business or Commerce plan - install WPCode, same process as self-hosted
  • Free, Personal, or Premium plan - you can't install plugins. Add the script tag and Lottie HTML together in a Custom HTML block on each page (requires admin role)

How to customize the Lottie animation

Add attributes to control playback, triggers, and rendering. Everything is configured through HTML - no JavaScript needed.

Play on scroll - the animation triggers when the user scrolls to it:

<div ot="lottie" ot-path="animation.json" ot-trigger="scroll" ot-loop="false" style="width: 200px; height: 200px;"></div>

Play on hover - animation starts when the mouse enters the element:

<div ot="lottie" ot-path="animation.json" ot-trigger="hover" ot-hover-action="reverse" style="width: 200px; height: 200px;"></div>

Slow it down - set speed to half and disable looping:

<div ot="lottie" ot-path="animation.json" ot-speed="0.5" ot-loop="false" style="width: 300px; height: 300px;"></div>

For the full list of options, check the main Lottie animation guide.

Why not use a WordPress Lottie plugin instead?

You can. Plugins like Starter Templates (Kadence) and Elementor Pro have built-in Lottie widgets. But they come with tradeoffs:

  • Elementor's Lottie widget requires Pro (paid)
  • Plugin-based solutions are locked to that plugin - migrate to a different theme or builder and you lose your animations
  • Each plugin loads its own scripts and styles, adding weight to your pages

The OneType approach is platform-independent. The same HTML works whether you're using Gutenberg, Classic Editor, Divi, Beaver Builder, or any other setup. Switch themes, switch builders - the Lottie animations keep working because they're just HTML attributes.

Troubleshooting

  • Animation not showing? Check that the script tag is in the Header section of WPCode and that you saved changes. View the live page, not the editor preview.
  • Caching issue? If you're using WP Rocket, W3 Total Cache, or similar - clear your cache after adding the script tag.
  • Security plugin blocking it? Whitelist cdn.transforms.onetype.ai in your security plugin (Wordfence, Sucuri, etc.).
  • Custom HTML block not rendering? Make sure you're logged in as Admin. WordPress strips script-related HTML for lower roles.

Get started

Lottie is a premium transform on OneType Transforms. Grab a a paid plan (their pricing), get your script tag from the get started page, and start adding Lottie animations to your WordPress site.

More posts

All

Build it today. Pay when it goes live.

Every feature is unmetered while you build.

Start building