Wydajność

perf/img-modern-format

Photos and large raster images are served as AVIF or WebP at the size they are shown, not as large JPEG or PNG files.

umiarkowanaw przeglądarcefe-images

Dlaczego

Images are usually the heaviest part of a page. AVIF and WebP store the same photo in far fewer bytes than JPEG or PNG, and an image delivered larger than it is displayed wastes the difference on every visit. Both slow the Largest Contentful Paint and cost data on mobile.

Poprawka

Encode photos as AVIF (with WebP or JPEG fallback in <picture> if older browsers matter) and size them to the largest rendered width, with srcset and sizes for the others. Let the framework do it where it can: next/image, @nuxt/image, Astro's <Image>, Angular NgOptimizedImage with a loader, SvelteKit enhanced:img. Keep PNG for screenshots with sharp edges if AVIF looks worse, and SVG for logos and icons.

Przykłady

<!-- bad: a 2400 px JPEG shown at 800 px -->
<img src="hero.jpg" alt="Autumn collection" width="800" height="450">
<!-- good -->
<picture>
  <source type="image/avif" srcset="hero-800.avif 800w, hero-1600.avif 1600w" sizes="(width >= 60rem) 50vw, 100vw">
  <img src="hero-800.jpg" alt="Autumn collection" width="800" height="450">
</picture>

Źródła

Fakty

Identyfikator
perf/img-modern-format
Waga
umiarkowana
Sprawdzanie
w przeglądarce wymaga wyrenderowanej strony: audit --url
Dotyczy plików
page
Ten sam problem w
Lighthouse image-delivery-insight
Uczy jej skill
fe-images Images and media delivery
Od wersji
0.1.0

Plik reguły na GitHubie

Przeczytaj w terminalu

npx github:dawidolko/frontend-skills explain perf/img-modern-format