Performance
perf/gif-to-video
Animations longer than a small icon are shipped as a muted, looping MP4 or WebM video, not as a GIF over 100 KiB.
moderatestaticfe-images
Why
GIF compresses animation poorly: a few seconds of screen recording easily weighs megabytes, slows the page and costs mobile data. The same clip as MP4 or WebM is usually a small fraction of the size, and a <video> can also be paused.
Fix
Convert the GIF (for example with ffmpeg) and embed it as <video autoplay muted loop playsinline width height> with an MP4 and a WebM source. Respect reduced motion: do not autoplay when prefers-reduced-motion: reduce, and give a pause control when it plays longer than five seconds.
Examples
<!-- bad -->
<img src="demo.gif" alt="Adding an item to the cart">
<!-- good -->
<video autoplay muted loop playsinline width="640" height="360" aria-label="Adding an item to the cart">
<source src="demo.webm" type="video/webm">
<source src="demo.mp4" type="video/mp4">
</video>Sources
Facts
- Id
perf/gif-to-video- Severity
- moderate
- Check
- static checked in the source by
audit - Applies to
project- Same problem in
- Lighthouse
image-delivery-insight - Taught by the skill
fe-imagesImages and media delivery- Since version
- 0.1.0
Read it in the terminal
npx github:dawidolko/frontend-skills explain perf/gif-to-video