Why it’s hard to add animation to a website the right way
You can add animation to a website in about two minutes. Adding it so the page still loads fast on a phone and doesn’t annoy anyone takes more thought. A looping product clip can make your website feel alive, while a 6 MB GIF at the top makes it feel broken.
There are four practical formats, and each one has its own job. First, though, a look at why animations so often go wrong.
What makes animations slow or annoying
Most problems trace back to a handful of causes:
- Heavy files. GIF uses a lossless compression algorithm and is limited to 256 colors per frame. A few seconds of footage easily reaches a file size of several megabytes.
- The wrong element on top. If the animation is the biggest thing above the fold, the browser has to load it before it can report the page as visually complete. That hurts Largest Contentful Paint (LCP), one of Google’s Core Web Vitals.
- Everything loads at once. Multiple animations far down the page download on the first visit, even if nobody scrolls that far.
- No way to stop it. Endless motion next to text that people are trying to read pulls the eye away. For visitors with vestibular disorders it can cause dizziness or nausea.
- No text alternative. Search engines and screen readers can’t see what a moving image shows unless you tell them.
Option 1: Add a GIF to a website with the img tag
A GIF is just an image, so you display it like any other image. Here is an example using the <img> element:
<img src="/media/confetti.gif" alt="Confetti falling over a purple background" width="480" height="270" loading="lazy">
The width and height attributes reserve space so the layout doesn’t jump. The loading="lazy" attribute tells the browser to fetch the file only when it gets close to the screen. Leave it off for a GIF that sits at the very top of the page, since lazy loading the LCP image delays it.
GIFs make sense where video isn’t possible, such as email newsletters or some page builders. On your own site they’re usually the heaviest option for the same animation, so keep them short and small.
Option 2: Use MP4 or WebM video like a GIF
A short video can behave exactly like a GIF at a fraction of the file size. This is the HTML5 video version of the same animation, using four attributes on the <video> element (video autoplay loop muted playsinline):
<video autoplay loop muted playsinline poster="/media/confetti-poster.jpg" width="480" height="270">
<source src="/media/confetti.webm" type="video/webm">
<source src="/media/confetti.mp4" type="video/mp4">
</video>
What each one does:
autoplaystarts the video without a click.looprepeats it endlessly, like a GIF.mutedis required for autoplay. Browsers block autoplay with sound, so an unmuted clip will not start.playsinlinekeeps it in the page on iPhones instead of opening fullscreen.
The browser uses the first source it supports, so list WebM before MP4. MP4 alone works too. The poster image shows before the first frame loads and gives search engines a preview.
Option 3: CSS animations and transitions
For interface motion you often don’t need a media file. A few lines of style rules can fade, slide or pulse any element. For example:
.badge { animation: pulse 2s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.08); } }
.button { transition: background-color 0.2s; }
A transition changes a property smoothly when its state changes, such as on hover. An animation with @keyframes runs on its own, and you set its time, delay and number of repeats. Stick to transform and opacity where you can; the browser can animate those without recalculating the layout, so they stay smooth on slow phones.
This approach suits loaders, buttons, menus, news tickers and text effects. It weighs a few hundred bytes and stays sharp at any size, but it can’t show footage.
Option 4: Lottie animations
Lottie is a JSON format for vector animations, usually exported from Adobe After Effects with the Bodymovin plugin. A small JavaScript player draws the animation in the browser, so it stays crisp on any screen and the file is often tiny compared with a GIF of the same illustration. You can also control it from code: play, pause, jump to a frame, react to scroll.
You pay with an extra script, and someone has to design the animation. Lottie suits icons, illustrations and animated logos.
Animation in WordPress: Video and Image blocks
WordPress handles both media options without code:
- Video that behaves like a GIF: insert a Video block and upload your MP4. In the block settings sidebar, turn on Autoplay, Loop and Muted, plus Play inline. Turn off Playback controls if you want a clean GIF look, set Preload to None or Metadata, and choose a Poster image.
- GIF: insert an Image block and upload the GIF file. Under Resolution, pick Full Size so visitors get your original file, and fill in the Alternative text field in the Content tab.
- Code snippets: paste HTML and CSS into a Custom HTML block.
Practical tips for performance, accessibility and SEO

Keep performance high
- Convert long GIFs to MP4. Google’s web.dev codelab shrank a 3.7 MB GIF to a 551 KB MP4 and a 341 KB WebM.
- Lazy load images below the fold.
loading="lazy"doesn’t work on<video>, so usepreload="none"with a poster there. - Don’t put a heavy animation in the hero. If you must, a light poster image keeps LCP fast.
Respect people who don’t want motion
Understanding Success Criterion 2.2.2 (Pause, Stop, Hide) from the W3C sets the rule: if moving content starts automatically, lasts more than five seconds and appears alongside other content, users need a way to pause, stop or hide it. Practical consequences:
- Give looping videos a pause button or show the controls.
- Prefer short loops that stop on their own for decorative motion.
- Turn animations off for visitors whose system asks for reduced motion:
@media (prefers-reduced-motion: reduce) {
* { animation: none !important; transition: none !important; }
}
Visitors can’t pause a GIF, so use video or CSS for anything that loops longer than five seconds.
Help search engines understand it
- Write a real alt text for every GIF: describe what happens, not “animation”.
- Set a poster image for every video and write a caption or nearby text that explains the clip.
- Use descriptive file names like
confetti-loop.mp4instead offinal2.mp4.

Where to get ready-made animations
Here is a shortcut. Our free animation gallery has seasonal loops as MP4 and GIF, so you can use the video version on your site and keep the GIF for email. The News Ticker generator and the Menu & Button Builder give you finished HTML and CSS to paste into a page. The Banner Maker exports an HTML5 banner as a ZIP. Two newer tools are worth a look as well: the CSS Loader Generator and the Text Animation Generator. All run in your browser without an account.
FAQ
How do I add animation to my website without code?
In WordPress, a Video block with Autoplay, Loop, Muted and Play inline turns an MP4 into a GIF-style loop. For a GIF, use an Image block.
Is GIF or video better for your website?
Video, in almost every case. An MP4 or WebM is much smaller for the same animation, supports millions of colors and can be paused. Use GIF where video isn’t allowed, such as most email clients.
Do animations slow down a website?
Heavy ones do. A large GIF or video above the fold can delay LCP and the time until your website looks ready. CSS animations on transform and opacity cost almost nothing.
Are animations bad for SEO?
No, as long as the page stays fast and the content is described. Add alt text to GIFs, poster images and captions to videos, and keep important text as real text instead of baking it into the animation.
Why won’t my video autoplay?
Usually because it isn’t muted. Add muted and playsinline, and check that the file is MP4 (H.264) or WebM.