Skip to content

Images in older formats

image-format-legacyminor
On this page

Why it matters

  • AVIF and WebP are newer than JPEG and PNG, and store the same image in far fewer bytes.
  • Every current browser shows them: Chrome, Firefox, Safari and Edge.
  • And images are often the heaviest part of a page, so making them smaller is one of the quickest ways to speed it up.

Example

Wrong
<img src="/images/sadu.png" width="128" height="128" alt="نقش سدو أحمر ورملي" />
Right
<img src="/images/sadu.webp" width="128" height="128" alt="نقش سدو أحمر ورملي" />

How to fix

Convert images to AVIF or WebP, with a tool such as Squoosh or your content delivery network's image service, and serve them with <picture> and a fallback for older browsers:

html
<picture>
  <source srcset="sadu.avif" type="image/avif" />
  <source srcset="sadu.webp" type="image/webp" />
  <img src="sadu.jpg" width="128" height="128" alt="Sadu pattern" />
</picture>
  • Icons and simple drawings suit SVG.

How we detect

  1. We render the page and read the images the browser drew, with each file's format, size and dimensions in pixels (the file's own, not the size it is drawn at).
  2. For an image in JPEG, PNG or BMP, we estimate its size as AVIF from its pixels: 2 bytes per pixel, compressed 12 to 1. Lighthouse 12 re-encoded each image in Chrome and estimated AVIF from those sizes, and used this estimate only for an image it could not re-encode; we use it for every image, in every engine. GIF is left out, as Lighthouse 12 left it out.
  3. The rule fails when the file is larger than that estimate by 8,192 bytes or more: Lighthouse 12's own limit.
  4. We report each image once, at the first element that shows it.