Wydajność
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.
umiarkowanastatycznefe-images
Dlaczego
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.
Poprawka
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.
Przykłady
<!-- 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>Źródła
Fakty
- Identyfikator
perf/gif-to-video- Waga
- umiarkowana
- Sprawdzanie
- statyczne sprawdzane w kodzie źródłowym przez
audit - Dotyczy plików
project- Ten sam problem w
- Lighthouse
image-delivery-insight - Uczy jej skill
fe-imagesImages and media delivery- Od wersji
- 0.1.0
Przeczytaj w terminalu
npx github:dawidolko/frontend-skills explain perf/gif-to-video