Fixing Lighthouse’s Suggestion to Replace Animated GIFs with Video
When Lighthouse 13 shows "Using video formats instead of GIFs can improve the download size of animated content" under "Improve image delivery," convert the GIF to an MP4 or WebM video. Replacing the <img> with <video autoplay loop muted playsinline> removes the warning. Check this when a page with an animated GIF loads slowly, or when you want to reduce LCP (the time until the largest image, text block, or video in the viewport is displayed).
In my test, a 645,936-byte GIF became 148,375 bytes as MP4 and 92,984 bytes as WebM.
The test environment was Ubuntu 24.04, Node.js 22, and Lighthouse 13.6.0 (the npm package). I ran Lighthouse from the command line with the default settings (mobile) and checked only the performance category. I used Chrome for Testing 158, bundled with Playwright 1.63.0, and specified it with the CHROME_PATH environment variable. I used FFmpeg 6.1.1 for the conversion. The test GIF was a 480×270, 15fps, 4-second (60-frame) animation generated from ffmpeg's test pattern (testsrc2). It was not a GIF from a real site. I did not test the Lighthouse panel in Chrome DevTools, PageSpeed Insights, desktop settings, playback in Safari or on iPhone, or converting to video with an image CDN.
The warning appears under "Improve image delivery"
I created a page with a single animated GIF and ran Lighthouse on it. A small Node.js server returned the page and the GIF, with the GIF sent as image/gif. I extracted the relevant parts of the JSON result with a small script (summarize.mjs).
<img src="/anim.gif" alt="動く図形のアニメーション" width="480" height="270">
$ npx lighthouse http://localhost:8080/gif.html --only-categories=performance --output=json --output=html --output-path=./out/gif --chrome-flags="--headless=new --no-sandbox" --quiet
exit: 0
$ node summarize.mjs out/gif.report.json
lighthouseVersion: 13.6.0 formFactor: mobile
performance score: 88 LCP: 3.9 s total-byte-weight: 646961
image-delivery-insight: score=0 displayValue="Est savings of 429 KiB" title="Improve image delivery" metricSavings={"FCP":0,"LCP":2100}
- http://localhost:8080/anim.gif totalBytes=645936 wastedBytes=439236
reason: Using video formats instead of GIFs can improve the download size of animated content wastedBytes=439236
(Some lines are omitted.)
In the HTML report, the item "Improve image delivery" appears with a red triangle. When you expand it, the GIF row appears, followed by the reason text and the estimated size reduction (Est Savings) below it.

With --locale=ja, the item name and reason are shown in Japanese. The item name means "Improve image delivery," and the reason means "Using video formats instead of GIFs can improve the download size of animated content, potentially."
Up to Lighthouse 12, this was a separate item called "Use video formats for animated content" (efficient-animated-content). The official explanation of that item says it moved to "Improve image delivery" in Lighthouse 13. In the 13.6.0 JSON result, efficient-animated-content does not exist, and the GIF warning appears only in image-delivery-insight.
The warning appears for GIFs over 100 KiB
The logic is in ImageDelivery.js in the @paulirish/trace_engine package (0.0.67), which Lighthouse 13.6.0 uses. ImageDelivery.ts in the Chrome DevTools repository has the same values.
GIFs are checked separately from other images. If the Content-Type is image/gif and the size is over 100 KiB (102,400 bytes), Lighthouse shows the message suggesting video. The estimated reduction is determined by this formula:
減らせる割合 = round(29.1 × log10(GIF のバイト数) − 100.7) ÷ 100
For a 645,936-byte GIF, the ratio is 0.68, so the estimated savings are 439,236 bytes. This matches the "Est Savings" value in the report (428.9 KiB). A comment in the code says this is an approximate ratio based on converting 1,000 real GIFs to video.
I found these other behaviors in the check:
| Image | Size | Lighthouse result |
|---|---|---|
| Animated GIF (480×270, 60 frames) | 645,936 bytes | Video suggestion, estimated savings 429 KiB |
| Animated GIF (120×120, 20 frames) | 39,041 bytes | No warning |
| Single-frame GIF (400×400) | 204,367 bytes | Video suggestion, estimated savings 108 KiB |
The 120×120 GIF uses about 2.7 bytes per pixel, but Lighthouse showed nothing for it because GIFs at or under 100 KiB are not flagged. For GIFs, the code does not look at the bytes per pixel.
The single-frame GIF also got the "use video" message once it exceeded 100 KiB. The code does not check whether the image is animated. If the image does not move, use PNG or WebP instead of video. The official explanation of Improve image delivery also recommends MPEG4 or WebM for moving content and PNG or WebP for still images.
Convert to MP4 and WebM with ffmpeg
I used the commands from web.dev's article on replacing animated GIFs with video, changing only the file names.
$ ffmpeg -i anim.gif -b:v 0 -crf 25 -f mp4 -vcodec libx264 -pix_fmt yuv420p anim.mp4
$ ffmpeg -i anim.gif -c vp9 -b:v 0 -crf 41 anim.webm
The MP4 was encoded with H.264 and the WebM with VP9. ffprobe confirmed that both are 480×270, 15fps, 4 seconds, and 60 frames, the same as the GIF.

Compared with the GIF, the MP4 is about 77% smaller and the WebM is about 86% smaller. The actual reduction was larger than Lighthouse's estimate of 68%.
I also compared image quality with ffmpeg's ssim filter. SSIM measures how similar two videos are, and comparing the GIF with itself gives 1. Compared with the GIF, the MP4 scored 0.953 and the WebM scored 0.951. Both are below 1. A number alone does not show visible differences, so before replacing the GIF, it is worth watching the converted video side by side with the original.
Replace img with video
To reproduce the GIF's motion with <video>, add the four attributes autoplay, loop, muted, and playsinline.
<video autoplay loop muted playsinline width="480" height="270" poster="/anim-poster.png">
<source src="/anim.webm" type="video/webm">
<source src="/anim.mp4" type="video/mp4">
</video>
According to the web.dev article, each attribute does the following:
autoplay: starts playing automatically, as a GIF doesloop: repeats playback, as a GIF doesmuted: produces no soundplaysinline: plays inside the page instead of going fullscreen
MDN's video element reference says that current browsers block autoplay for videos with sound. The web.dev article also shows the form with muted.
When you list several <source> elements, the browser uses the first one it supports. I put WebM first and MP4 second. The official Improve image delivery explanation says that iPhones before iOS 16 cannot play WebM, so I kept MP4 as a fallback.
poster sets an image to show while the video loads. Here I exported the GIF's first frame as a PNG (15,030 bytes) and used it.
$ ffmpeg -i anim.gif -frames:v 1 anim-poster.png
When I opened this page in the same Chrome that Lighthouse uses, WebM was selected (currentSrc was anim.webm). Reading currentTime every 0.5 seconds showed that after 3.5 seconds it returned to 0.0, so the video was looping. On a version of the page with the WebM <source> removed, leaving only MP4, MP4 was selected and the playback position advanced.
The alt attribute from the <img> does not exist on <video>. If you described the GIF's content in text (in its alt attribute), keep that description some other way, for example by writing it in the body text.
Lighthouse results after the replacement
When I ran Lighthouse on the page with <video>, the "Improve image delivery" warning did not appear.
$ node summarize.mjs out/video.report.json
lighthouseVersion: 13.6.0 formFactor: mobile
performance score: 100 LCP: 0.9 s total-byte-weight: 109363
image-delivery-insight: score=1 displayValue="" title="Improve image delivery" metricSavings={"FCP":0,"LCP":0}
request: http://localhost:8080/anim-poster.png mimeType=image/png statusCode=200 transferSize=15203 resourceSize=15030
request: http://localhost:8080/anim.webm mimeType=video/webm statusCode=206 transferSize=93207 resourceSize=92984
(Some lines are omitted.)
Only the poster PNG and the WebM were loaded. The MP4 was not loaded. The total page weight (total-byte-weight) went from 646,961 bytes to 109,363 bytes.
| Page | Performance score | LCP | LCP element |
|---|---|---|---|
| GIF | 88 | 3.9 s | <img src="/anim.gif"> |
| video (WebM and MP4, with poster) | 100 | 0.9 s | <video> |
| video (MP4 only, no poster) | 100 | 0.8 s | <video> |
The "Improve image delivery" item itself is marked "Unscored" in the report, so it does not count directly toward the score. In the GIF page's result, the item's metricSavings was "LCP":2100, meaning that fixing the GIF was estimated to cut LCP by about 2.1 seconds. In practice, the replacement page's LCP dropped from 3.9 seconds to 0.9 seconds, and the score went up. When I ran the GIF page again with Japanese display text, LCP was 4.1 seconds and the score was 87. Lighthouse numbers change a little from run to run.





