Yes, for almost any animated GIF on a web page: turn it into a short, muted, looping video (MP4, plus WebM if you can), and use animated WebP when it has to stay an image. On 34 real animated GIFs, MP4 came out at a median 12% of the GIF's size and WebM at 9%. Lossy animated WebP came in at 40%, and a lossless animated WebP, which keeps every pixel, at 71%. The exceptions are tiny GIFs with flat colors, which a lossy format can make bigger.
How much smaller is WebP or MP4 than a GIF?
We took 34 animated GIFs from the featured collection on Wikimedia Commons (diagrams, scientific animations, a webcam animation, Muybridge's galloping horse) and converted each one four ways on Nov 30, 2026. Our search found 45 featured GIFs; Commons began refusing our downloads after 34, so those 34 are the sample. The median GIF was 402 KB, about 47 frames, and about 400 by 400 pixels.
| Format | Median size vs the GIF | Range across the 34 | All files together | Came out larger than the GIF |
|---|---|---|---|---|
| WebM (VP9) | 9% | 0.9% to 109% | 16% | 1 of 34 |
| MP4 (H.264) | 12% | 1.3% to 142% | 29% | 2 of 34 |
| Animated WebP, lossy (quality 75) | 40% | 2.8% to 161% | 42% | 7 of 34 |
| Animated WebP, lossless | 71% | 36% to 129% | 70% | 1 of 34 |
WebM was the smallest of the four for 26 of the 34 GIFs, MP4 for 5 and lossless WebP for 3. MP4 was smaller than lossy WebP for 33 of the 34.
That agrees with what others have found. web.dev's own example went from a 3.7 MB GIF to a 551 KB MP4 (15%) and a 341 KB WebM (9%). Google's WebP FAQ says GIFs converted to lossy WebP are 64% smaller and to lossless WebP 19% smaller, on an older test set; ours were 60% and 29% smaller by median.
How we measured
- MP4 and WebM with ffmpeg 9.0.2, using web.dev's settings:
ffmpeg -i in.gif -b:v 0 -crf 25 -f mp4 -vcodec libx264 -pix_fmt yuv420p -vf "crop=trunc(iw/2)*2:trunc(ih/2)*2" out.mp4andffmpeg -i in.gif -c vp9 -b:v 0 -crf 41 -pix_fmt yuv420p out.webm. We had to add-pix_fmt yuv420pto the WebM command, which ffmpeg 9 otherwise refused. - Lossy animated WebP with ffmpeg's libwebp encoder:
-c:v libwebp_anim -lossless 0 -quality 75 -loop 0. - Lossless animated WebP with the encoder Heart Photos itself uses for GIFs (libwebp 1.6.0's
cwebp -lossless -z 9 -exacton every frame). At that effort it was by far the slowest of the four to make.
The sizes depend heavily on what moves. A 26 MB webcam animation became a 0.8 MB MP4 (3%). A 51 KB chessboard animation with a few flat colors became a 69 KB MP4 (135%), and a 253 KB map with flat colors grew as lossy WebP and as MP4 but shrank to 74% as lossless WebP.
Which should you use?
| If you want to | Use |
|---|---|
| The smallest file for a looping animation on a web page | WebM and MP4 in a video element |
Keep the file in an img tag, a CMS image field or Markdown |
Animated WebP |
| Keep every pixel exactly, or keep transparency | Lossless animated WebP |
| Send it in a chat app or email | GIF, which is still the format every program opens |
| A tiny animation with a few flat colors | Try lossless WebP, and keep the GIF if nothing beats it |
Browser support is no longer the deciding factor. Can I use showed, for StatCounter's October 2026 figures: MP4 with H.264 at 97.57%, WebM at 97.38% and WebP at 97.32%. MDN's image format guide calls WebP an "excellent choice for both images and animated images", and suggests WebP, AVIF or APNG over GIF for animation.
How do you replace a GIF with a video?
Convert it with the commands above, then use a video element that behaves like a GIF: it plays by itself, loops, has no sound and stays in the page on phones.
<video autoplay loop muted playsinline width="400" height="400">
<source src="animation.webm" type="video/webm">
<source src="animation.mp4" type="video/mp4">
</video>
The browser takes the first source it can play, so WebM goes first and MP4 is the fallback. muted matters: Chrome's autoplay policy says plainly that "muted autoplay is always allowed", while a video with sound may not start. Keep width and height so the page does not jump while it loads, as with any image.
Lighthouse has long flagged GIFs with its "Use video formats for animated content" audit, which has moved into the Improve image delivery insight as of Lighthouse 13. Our post on fixing Improve image delivery in PageSpeed Insights covers the rest of that insight.
What do you give up?
- Exact pixels. MP4, WebM and lossy WebP are lossy: they throw information away, which is where most of the saving comes from. Thin lines and text can soften, and
yuv420pstores color at half the resolution. If that matters, lossless WebP keeps every pixel. Our post on lossy vs lossless compression explains the difference. - Transparency. 19 of our 34 GIFs had a transparent color in their palette. The MP4 and WebM made above have no transparency at all, so anything see-through comes out filled in. Animated WebP keeps it.
- Decoding effort. Google's FAQ notes that, played straight through, lossy WebP takes 2.2 times as long as GIF to decode and lossless WebP 1.5 times as long.
- Simplicity. A GIF is one file in an
imgtag. A video is a different element with its own attributes, and some editors and platforms only take images.
Frequently asked questions
Is WebP better than GIF for animations?
In file size, almost always. Lossy WebP was smaller than the GIF for 27 of our 34, and lossless WebP for 33 of 34. A GIF holds at most 256 colors per frame, while WebP has full color and an alpha channel. GIF still wins on one thing: every program, chat app and email client can show it.
Is MP4 smaller than a GIF?
Usually by a lot: a median 12% of the GIF in our test, and 3% for the webcam animation. It was larger only for two small GIFs with flat colors.
Does converting a GIF to MP4 lose quality?
Yes, a little, because H.264 is lossy. At the settings above the difference is hard to see in motion, but fine lines and small text can blur. Keep the GIF if you may need it again.
Can an MP4 replace a GIF on a website without a play button?
Yes. With autoplay loop muted playsinline and no controls attribute, it starts on its own, repeats and shows no controls, just as a GIF does.
Should I use animated AVIF instead?
MDN calls animated AVIF a good choice, with "much better compression" than GIF, and says Firefox has played it since version 113. It is newer and fewer tools make it, so for now WebM and MP4 for video and WebP for an image are the easier, well-tested pair.
What Heart Photos does with GIFs
Upload an animated GIF to Heart Photos and it gets the Animated tag, which you can click to see only your animated images. It plays in the viewer, where you can pause it and move through it frame by frame on its seek bar.
Behind that, the library keeps your GIF as a lossless animated WebP, frame for frame, with the same timing and the same number of loops. It keeps the WebP only after checking that every frame matches the GIF exactly and that the file is smaller; a GIF like the one in our test that grew stays a GIF. No pixel, frame or bit of timing is lost, and the file takes less of your storage.
To try it, open Heart Photos and upload a GIF. If you are deciding on formats for still images too, our comparison of AVIF, JPEG XL and WebP and PNG vs WebP are the next reads.