Updated: August 1, 2026
Short answer: Test AVIF and WebP from the same source at the same displayed dimensions. AVIF often produces the smaller photographic file, while WebP is usually cheaper to encode and is a practical fallback. For public pages, serve a format the client can decode and keep JPEG or PNG when compatibility requires it.
“AVIF or WebP?” is not a permanent site-wide decision. It is a delivery decision for a particular image, audience, and pipeline. A CDN can serve AVIF to a client that accepts it, WebP to another client, and an optimized JPEG or PNG to a third. A static build can generate several variants once and select them with <picture>.
AVIF vs WebP at a Glance
| Decision | AVIF | WebP |
|---|---|---|
| Photographic file size | Often smaller at a similar visual target | Usually efficient and predictable |
| Encoding cost | More expensive in many pipelines | Commonly faster and lighter to encode |
| Lossy images | Yes | Yes |
| Lossless images | Yes | Yes |
| Transparency | Yes | Yes |
| Animation | Yes | Yes |
| HDR and wide color | Strong support | More limited than AVIF for advanced color workflows |
| Fallback need | Yes for mixed clients | JPEG or PNG may still be needed |
| Best fit | Static modern web delivery | Broad modern delivery and fast pipelines |
The table describes trade-offs, not guaranteed rankings. The result changes with source content, encoder version, quality target, dimensions, and whether the image is a photo, screenshot, logo, or transparent cut-out.
What the Search Results Emphasize
Current results for “AVIF vs WebP” tend to reward pages that answer two practical questions early: which format is smaller, and how should a site serve both without breaking clients. The strongest technical angle is not another list of unsupported browser percentages; it is the relationship between encoding cost and per-request delivery.
ModPageSpeed’s current comparison makes this distinction explicit: AVIF is often smaller, WebP is cheaper to produce, and format selection can happen per request through content negotiation. The MDN format guide similarly recommends AVIF with a fallback and notes that WebP does not have the same historical depth of support as JPEG or PNG.
File Size Is Only One Half of the Decision
AVIF’s advantage is most visible when a static image can be encoded ahead of time. If a server must decode a source and encode AVIF during every request, the smaller response may be offset by CPU time, cache misses, latency, or memory pressure. Generate variants at build time or in a background image pipeline when possible.
WebP is often attractive for systems that resize images on demand. It offers lossy and lossless modes, alpha transparency, and animation, while the encoding toolchain is widely available. This does not make WebP automatically better: a pre-generated AVIF can be the better public delivery asset when the client supports it and the page benefits from fewer bytes.
Quality Comparison: Use the Same Source and the Same Target
Do not compare an AVIF exported from a large original with a WebP exported from an already-compressed JPEG. That tests the source history, not the formats. Use this workflow:
- Start with the highest-quality source you own.
- Resize every candidate to the same pixel dimensions.
- Export AVIF and WebP at settings that produce a similar visual result.
- Compare faces, gradients, texture, dark shadows, and fine edges at 100%.
- Compare again at the real CSS display size.
- Record file size, encode time, decode behavior, and fallback requirements.
For a reproducible metric, a tool can calculate SSIM or another perceptual measure, but a metric does not replace a visual check. A screenshot, a product label, or a transparent edge may fail in a way a broad average does not reveal.
When AVIF Is the Better Choice
Choose AVIF as a candidate when:
- the image is a large static photograph or hero asset;
- the build or CDN can encode and cache it before a visitor waits;
- your audience is covered by a tested fallback path;
- HDR, wide gamut, or higher color depth is part of the workflow;
- the smaller transfer outweighs encoding and decoding costs.
AVIF supports alpha, animation, HDR, and wide color gamut. The AOMedia AVIF specification is the right source for format capabilities. It does not tell you whether a specific CMS, email client, or upload form accepts AVIF; that needs a destination test.
When WebP Is the Better Choice
Choose WebP when:
- the image is generated or resized in real time;
- the pipeline already has reliable WebP tooling;
- you need one modern format for lossy photos, lossless graphics, and alpha;
- the audience includes clients where AVIF support or decoding is uncertain;
- the simpler delivery path is more valuable than the last bytes saved.
Google’s published WebP study found 25–34% smaller files than comparable JPEG files at equal SSIM in its test sets, and Google’s WebP documentation reports about 26% smaller lossless WebP files than PNG on average. These results are useful reference points, not a promise that WebP will beat AVIF or shrink every individual image. See the WebP compression study.
Serve Both Safely
For an HTML image, use a fallback chain:
<picture>
<source srcset="photo.avif" type="image/avif" />
<source srcset="photo.webp" type="image/webp" />
<img src="photo.jpg" width="1200" height="800" alt="Mountain lake at sunrise" />
</picture>
For a CDN or server, content negotiation can select a variant based on the client’s Accept header. Verify three things in production:
- the response
Content-Typematches the actual bytes; - caches vary on the format decision, such as
Vary: Acceptwhere appropriate; - a client that does not support AVIF never receives an AVIF body accidentally.
The simplest architecture is often the most reliable: pre-generate AVIF and WebP, keep the original, and let the HTML or CDN choose. Do not add a complex negotiation layer if the site cannot test cache behavior.
Avoid These Format Mistakes
- Encoding AVIF on the request path without measuring latency.
- Sending AVIF without a fallback to older browsers, webviews, email, or upload systems.
- Treating quality 60 in AVIF and quality 60 in WebP as equivalent.
- Re-encoding a compressed JPEG instead of returning to the master.
- Choosing a modern format but still sending desktop-sized pixels to a phone.
- Assuming a smaller file automatically improves LCP when the image is discovered late or lazy-loaded incorrectly.
Static Builds vs Request-Time Conversion
The right format can change depending on where encoding happens. A static build can take the original source, create AVIF and WebP variants once, and publish them with predictable URLs. This is a good fit for blog images, product catalogs, and assets that change occasionally.
Request-time conversion is more flexible but needs protection against slow cache misses. The first visitor may trigger a decode and one or more encodes, so measure the cold request as well as the warm cache. If an image CDN negotiates formats, make sure the cache key distinguishes the accepted format and that the response headers describe the variation correctly.
For a small site, pre-generated variants plus <picture> are often easier to inspect. For a large site, a CDN may reduce operational work by negotiating AVIF, WebP, and the optimized original automatically. Neither architecture is inherently better; the reliable choice is the one you can observe and invalidate safely.
A Small Test Matrix
Use a representative sample instead of one convenient photograph:
| Test asset | What to inspect | Why it matters |
|---|---|---|
| Bright product photo | gradients, label text, edges | reveals banding and color shifts |
| Dark or noisy photo | shadows, texture, fine detail | reveals blocking and loss of detail |
| Screenshot | letters, thin rules, flat colors | reveals blur and ringing |
| Transparent cut-out | fringe on light and dark backgrounds | reveals alpha/RGB interaction |
| Large hero image | request timing and decode | connects format choice to LCP |
Record the dimensions, output bytes, encode time, and visual result for each candidate. If the difference is small, prefer the format that your team can generate, cache, debug, and replace reliably. A theoretical saving that nobody can verify is not a production advantage.
When Neither AVIF nor WebP Is Right
Use JPEG when an upload form or email client requires it. Use PNG when exact pixels, broad compatibility, or editing matters. Use SVG when the source is simple vector artwork. Use a short video when an animated image would be too heavy. The correct optimization is sometimes choosing a different asset type, not tuning the same codec harder.
Related LessMB Guides
- JPEG vs PNG vs WebP vs AVIF: the complete format decision
- WebP vs JPEG for website images
- Image compression and Core Web Vitals
- Best image compression settings for websites