AVIF, WebP or JPEG: which to serve
AVIF, WebP and JPEG compared with MDN's support data, plus file sizes I measured on 22 blog covers, and how to serve fallbacks with the picture element.
· Updated · 4 min read

Serve AVIF where you can, WebP as the next choice and JPEG or PNG as the fallback. All three formats are supported by the major browsers today, AVIF compresses best in my test, and the picture element lets each browser take the first format it understands.
The support and format facts below are from MDN's guide to image file types. The sizes are from a small test of my own on 22 images, and I describe its limits so you can judge how far to trust it.
What MDN says about each format#
AVIF. MDN calls it a good choice for images and animated images because of its high performance and its royalty-free licence. It supports lossy and lossless compression, animation and high dynamic range. The listed support is Chrome 85, Edge 121, Opera 71, Firefox 93 and Safari 16.1. AVIF does not support progressive rendering, so a file has to be fully downloaded before it can be shown.
WebP. MDN calls it an excellent choice for images and animated images, with broad support in the latest versions of major browsers, though not deep historical support. On Safari for macOS it needs Safari 14 and macOS Big Sur or later. Lossy WebP images are on average 25 to 35 percent smaller than JPEG images of visually similar compression levels, and lossless WebP images are typically 26 percent smaller than the same images as PNG.
JPEG and PNG. MDN recommends JPEG as the fallback for photographs and PNG for screenshots, line art and images with transparency.
MDN's advice for AVIF is to provide a fallback in WebP, JPEG or PNG with the picture element, because support has little historical depth.
My test: 22 covers in four formats#
Every post on this blog has a 1200 × 630 cover. I took the covers of the first 22 posts as WebP files, decoded each and re-encoded it with the sharp library (version 0.35.5):
| Format | Settings | Total for 22 covers |
|---|---|---|
| WebP | the files as published | 811 KB |
| AVIF | quality 60, effort 4 | 585 KB |
| JPEG | quality 86, mozjpeg | 1,195 KB |
| PNG | compression level 9 | 7,797 KB |
On these images, AVIF came out about 28 percent smaller than WebP, and JPEG about 47 percent bigger than WebP. PNG is far larger, because the covers are detailed screenshots with gradients.
Please read the limits before you quote these numbers:
- The quality numbers of different codecs are not equivalent. I chose settings that I expected to look alike and did not measure visual similarity, so one format may look worse than another at its size.
- The source was already a lossy WebP, so every re-encode starts from an image that has lost some detail.
- The covers are dark screenshots and cards, not photographs. Photos can behave differently.
For your own images, a tool that lets you compare the results side by side is the safest way. My Compress Image to Size tool takes a target size and finds the best quality that fits, with a before and after slider, and it runs in your browser. It outputs JPEG or WebP, not AVIF.
Serving fallbacks#
The picture element lists sources in order of preference, and the browser takes the first one it supports:
<picture>
<source srcset="cover.avif" type="image/avif" />
<source srcset="cover.webp" type="image/webp" />
<img src="cover.jpg" width="1200" height="630" alt="A description of the image" />
</picture>
Always put the width, height and alt on the img, as MDN's own example does. The dimensions let the browser reserve space before the image loads.
Where I still use JPEG#
The blog covers show as WebP on the page. For link previews I serve a JPEG copy, because I could not show that every preview crawler handles WebP. I wrote about that in Open Graph images: size, format and tags. AVIF has the same question mark for link previews, so I have not used it there. The Lab cards use WebP stills with a short MP4 that loads only on hover; how that works is in Hover video previews that load on demand.
A simple rule#
- Photos and large hero images: offer AVIF and WebP, with a JPEG fallback.
- Logos, icons and diagrams: SVG first. Screenshots and flat graphics: lossless WebP, with a PNG fallback.
- Anything a third-party crawler reads, such as
og:imageor an RSS image: JPEG or PNG. - Measure the result. A smaller file is the goal, but a visibly worse image is not a saving.
Limits of this post#
I did not compare image quality with a metric or test the formats in every browser. The support versions come from MDN's guide, and browsers change, so check their compatibility tables for current numbers. The size test used one set of 22 images and one set of encoder settings.