Web Speed

WebP vs AVIF: Compressing Images Without Wrecking Quality

Images are usually the heaviest thing on a page, so the format you serve them in matters more than almost any other optimization. The two modern options, WebP and AVIF, both beat JPEG and PNG, but they’re not interchangeable. In the WebP vs AVIF choice, picking wrong either wastes bytes or wastes your time.

Side-by-side comparison illustration of WebP versus AVIF, WebP vs AVIF: Compressing Images Without Wrecking Quality
WebP vs AVIF: the trade-offs, side by side.

WebP is the safe default

WebP is about 25 to 35% smaller than JPEG at the same quality, supports transparency, and works in every browser people actually use. Converting a library to WebP is the single biggest image win for most sites, and it’s low-risk.

It also encodes quickly, so generating it on upload doesn’t strain a modest server. It handles both photos (lossy) and flat graphics (lossless), which means one format can replace most of the JPEGs and PNGs in a typical media library.

AVIF goes further, with tradeoffs

AVIF is often 50% smaller than JPEG, with better detail in gradients and dark areas. But encoding is slow and CPU-heavy, so generating it on the fly can hurt the server, and very old browsers don’t support it. For photography-heavy sites where every kilobyte counts, AVIF is worth it. For a typical business site, the extra savings over WebP often aren’t.

If you want to check support for your own audience, Can I use lists AVIF support by browser version. Current versions of the major browsers handle it. The gap is older devices that never get updated, which is exactly why a fallback matters.

WebP vs AVIF at a glance

WebPAVIF
File sizeClearly smaller than JPEGUsually smaller again than WebP
TransparencyYesYes
Encoding speedFastSlow and CPU-heavy
Browser supportEvery current browserCurrent major browsers, not very old ones
Best forAlmost every site, as the defaultPhoto-heavy pages where bytes really count
Infographic summarising “WebP vs AVIF: Compressing Images Without Wrecking Quality”: WebP is the safe default; AVIF goes further, with tradeoffs; WebP vs AVIF at a glance; Serve both with a fallback; Compressing without wrecking quality; Mistakes I see after a conversion
The article at a glance.

Serve both with a fallback

The pragmatic answer is to serve both with a fallback: AVIF if the browser takes it, WebP if not, original as a last resort. A <picture> element handles this, and most image plugins or a CDN like Cloudflare can do it automatically.

Written by hand, it looks like this. The browser reads the sources in order and uses the first one it understands:

<picture>
<source srcset="team.avif" type="image/avif">
<source srcset="team.webp" type="image/webp">
<img src="team.jpg" width="1200" height="800" alt="Our team at work">
</picture>

Keep the width, height and alt on the img tag. That one tag still controls the layout and the accessibility, whichever file the browser picks.

On WordPress you rarely need to write this yourself. Recent versions accept WebP and AVIF uploads as long as the server’s image library supports them, and image optimization plugins generate both versions and rewrite the markup for you.

Compressing without wrecking quality

The format is only half the job. The other half is how hard you squeeze, and that’s where sites end up with smeared, blotchy photos. A few rules keep the quality intact:

  • Resize before you compress. A 4000 pixel camera photo shown in an 800 pixel slot is wasted bytes no format can rescue. Export at the size you display, plus a larger version for high-density screens through srcset.
  • Start from the best original. Converting an already compressed JPEG stacks one set of artefacts on another. Keep the original high-quality file and convert from that.
  • Don’t trust one quality number. Quality scales differ between encoders and formats, so a setting that looks fine in WebP is not the same setting in AVIF. Lower it until you see damage, then step back one notch.
  • Check at 100% zoom. Look at skies and gradients for banding, faces and fabric for smearing, and edges of text for halos.

When neither format is the answer

Logos and icons are usually better as SVG: they stay sharp at any size and are often tiny. Screenshots full of text need a careful look, because aggressive lossy compression blurs letters first. Lossless WebP is often the safer choice there.

Mistakes I see after a conversion

  • Generating AVIF on every request with no caching, so the server re-encodes the same image again and again.
  • Deleting the original JPEGs, which leaves nothing for old browsers and nothing to re-convert from later.
  • Converting the media library but leaving hard-coded image URLs in the theme or page builder pointing at the old files.
  • Optimizing the format while the hero still loads last. A small file that starts late is still late, which is why lazy loading can make a site feel slower.

Page builders deserve a special mention, because images added through sliders and background sections often bypass the optimizer entirely. It’s one of several things that pile up and explain why Elementor sites become slow after six months. A custom website rather than a template can bake the right formats and sizes into every template from day one.

Don’t agonize over the choice. Convert to WebP today for an immediate win, and add AVIF later if your images are the kind where the extra compression actually shows. If images are only one of several things dragging your score down, my WordPress speed optimization service handles the formats, sizes and loading order together.

Questions people ask

Is AVIF better than WebP?

AVIF usually produces smaller files than WebP at similar visual quality, especially for photos with gradients and dark areas. The cost is slow, CPU-heavy encoding and missing support in very old browsers. For most business sites WebP is the sensible default, with AVIF added for photo-heavy pages.

Do all browsers support AVIF?

Current versions of the major browsers support AVIF, but older browsers and devices that are no longer updated do not. That is why AVIF should be served inside a picture element with a WebP and JPEG fallback, so every visitor still gets an image.

Should I convert all my images to WebP?

For most sites, yes. WebP is noticeably smaller than JPEG at the same quality, supports transparency and works in every current browser. Keep the original files as a fallback and a source for future conversions, and use SVG for logos and icons instead.

Does WordPress support AVIF images?

Recent WordPress versions accept AVIF uploads, as long as the image library on your server supports the format. If it does not, an image optimization plugin or a CDN can generate AVIF copies and serve them to browsers that accept them.

Comments

Leave a comment

0 / 3000
Comments are moderated. Links are not clickable and your email is never published. See the privacy policy.
keep reading

Related articles

Usually replies within a day
let’s talk

Tell me what you want to build

A website, an app, some automation, or something you’re still figuring out. Tell me the problem and I’ll give you a straight answer on what it takes. No pressure, no sales team.