Web Design

AVIF vs WebP vs JPEG vs PNG: Which Image Format to Use on Your Website

A macro photograph of dew drops of different sizes strung along a single strand of spider silk in soft early morning backlight, each drop holding the same tiny upside-down picture of a red flower in the blurred garden behind it, a visual for avif vs webp and how one picture can be stored in larger or smaller files

In the AVIF vs WebP choice, both formats beat JPEG and PNG on file size. Both work in every current major browser. AVIF usually makes the smaller file. WebP has been supported longer, so it is the safer middle step in a fallback chain.

Our guide to fixing a slow largest contentful paint explains where image download time fits, and why it is rarely the first fix. This piece goes deeper on format. It covers browser support, compression, transparency, when to keep JPEG and PNG, fallback markup, and what WordPress, Drupal and the server allow.

The short version on AVIF vs WebP: serve AVIF first with WebP or JPEG as the fallback. Keep PNG for screenshots and line art. Keep your original files and let the CMS generate the modern versions. First, check that the server can write AVIF.

AVIF vs WebP vs JPEG vs PNG at a glance

MDN’s image file type guide says to prefer WebP or AVIF for raster images. Both "generally provide better compression than PNG, JPEG, and GIF," it says.

Format Compression Transparency and animation Best use
AVIF Lossy and lossless Both First choice for photos and hero images
WebP Lossy and lossless Both Fallback for AVIF, or a single modern format
JPEG Lossy only Neither Final fallback for photos; originals
PNG Lossless only Transparency; animation needs APNG Screenshots, diagrams, logos; transparent fallback

AVIF vs WebP: compression and quality

Google’s WebP documentation gives the clearest published numbers for WebP. Lossy WebP files are "25-34% smaller than comparable JPEG images at equivalent SSIM quality index," it says. Lossless WebP is "26% smaller in size compared to PNGs."

AVIF claims are less tidy. The WordPress 6.5 dev note says AVIF can be "up to 50% smaller than JPEGs" at the same quality. web.dev’s AVIF compression article reports savings of "greater than 50%" against JPEG, but it also says results depend on the image, the encoder settings and the quality target. Its own sample pair saved far less than that.

Treat any single percentage as a ceiling and test your own images.

Encoding time also belongs in the AVIF vs WebP decision. AVIF encoders have a speed setting. PHP’s imageavif function runs from 0 (slow, smaller file) to 10 (fast, larger file), with 6 as the default. web.dev says higher speed settings "produce worse compression efficiency and quality."

One more difference: MDN notes that AVIF "does not support progressive rendering." A progressive JPEG, by contrast, can show a rough version while it loads.

Transparency, animation and color

  • Transparency. Google says transparency in lossless WebP costs “just 22% additional bytes.” Lossy WebP with transparency is typically about three times smaller than PNG. The AVIF specification from the Alliance for Open Media stores transparency as an alpha layer.
  • Animation. WebP supports animation, and Google says animated WebP can be smaller than GIF and APNG. AVIF supports image sequences. MDN lists Firefox 113 as the first Firefox version for animated AVIF.
  • Color. The AVIF specification covers high dynamic range (HDR) and wide color gamut.

When to keep JPEG and PNG

JPEG and PNG still have three jobs.

Fallbacks. MDN calls JPEG "often a good fallback format for photographs." PNG is the fallback for transparency. Any <picture> element needs one of them in the <img> tag.

Screenshots, diagrams and line art. MDN advises lossless encoding here. Blurring and color fringes around text are easy to see. PNG or lossless WebP both work.

Originals and images that leave your site. Keep the original so you can regenerate sizes later. Before switching a social share image or a newsletter image, check that the platform receiving it accepts the format.

The picture element with AVIF and WebP fallbacks

The <picture> element lets the browser pick the first format it can decode. Per MDN’s picture element reference, a browser skips any source whose type it does not support.

<picture>
  <source srcset="hero.avif" type="image/avif">
  <source srcset="hero.webp" type="image/webp">
  <img src="hero.jpg" width="1200" height="675" alt="Volunteers at a food bank">
</picture>

Three rules keep it working:

  1. Order matters. Put AVIF first, then WebP. The browser uses the first source it supports.
  2. The img is required. It is the fallback and carries the alt text, width and height.
  3. Reserve space. Set width and height so the page does not jump. Our guide to fixing CLS covers why.

Skip the fallback and you risk broken images. web.dev’s AVIF lesson warns that a browser without AVIF support discards the file.

Responsive images: srcset and sizes

Size matters as much as format. A 3,000-pixel AVIF shown at 600 pixels still wastes bytes.

<img src="hero-800.jpg"
  srcset="hero-480.jpg 480w, hero-800.jpg 800w, hero-1600.jpg 1600w"
  sizes="(max-width: 800px) 100vw, 800px"
  width="800" height="450" alt="Volunteers at a food bank">

srcset lists each file and its width. sizes tells the browser how wide the image will display. MDN’s responsive images guide explains the choice. The browser takes the first matching condition in sizes. Then it picks the closest file at least that wide.

Inside <picture>, each <source> can carry its own srcset and sizes. In practice, let the CMS write that markup.

A wrong sizes value is a common problem. Say a theme sets 100vw for a narrow sidebar image. Phones then download a file far wider than they show.

AVIF and WebP in WordPress

  • Responsive images, 4.4. Core adds `srcset` and `sizes` to images it renders, from the sizes it creates on upload. The wp_calculate_image_sizes filter changes the default `sizes`.
  • WebP uploads, 5.8. The WordPress 5.8 WebP dev note says sizes are made in the upload’s format. Uploads fail if the server lacks WebP support.
  • AVIF uploads, 6.5. The WordPress 6.5 AVIF dev note says you can upload AVIF like a JPEG if the host supports it.

Core does not convert JPEG uploads on its own. The 6.5 note shows the image_editor_output_format filter that does it:

add_filter( 'image_editor_output_format', function ( $formats ) {
  $formats['image/jpeg'] = 'image/avif';
  return $formats;
} );

That changes the generated sizes for new uploads. The wp_editor_set_quality filter sets compression.

The WordPress Performance Team’s Modern Image Formats plugin handles more. It picks AVIF if the server supports it and WebP if not. It can keep JPEG or PNG fallbacks for every size and output <picture> markup. It converts new uploads only. Older images need regenerating with WP-CLI’s wp media regenerate or a plugin.

AVIF and WebP in Drupal

Drupal handles formats through image styles. The image module documentation says a style can "convert image type" without changing the original.

Drupal 11.2 added two pieces:

  • GD support for AVIF. A Drupal 11.2 change record says the GD toolkit can now write AVIF. PHP’s GD must use libgd 2.3.2 or later, built with libavif.
  • A “Convert to AVIF (with fallback)” effect. The change record says it converts to AVIF where the server can. Elsewhere it uses a fallback style, such as WebP. AVIF is not the default because server support cannot be guaranteed.

The fallback effect exists for a reason. The core issue behind it says a plain AVIF conversion on a server without support left images not displaying.

Add the effect to the styles behind hero and card images. Then check the responsive image styles that use them. Since Drupal 10.1, the responsive image formatter also outputs width and height and has a lazy or eager setting.

Drupal 10 reaches end of life on December 9, 2026. The AVIF effect and GD’s AVIF support are in Drupal 11.2, not Drupal 10. Plan image work with the upgrade. See what Drupal 10 end of life means for your site and our plain-language Webform advisories explainer.

Server support: GD and Imagick

In practice, the server often settles AVIF vs WebP for you. Both CMSs depend on its PHP image library, and if it cannot write AVIF, no CMS setting fixes that.

  • GD. PHP added imageavif() in PHP 8.1. GD also needs a build with AVIF support, as noted above.
  • Imagick. WordPress can use Imagick or GD. Whether Imagick writes AVIF depends on how ImageMagick was built on that server.

In WordPress, open Tools, Site Health, Info, then Media Handling. Look for AVIF in the list. In PHP generally, gd_info() and imagetypes() report what GD can do. On an older PHP version? Our post on PHP 8.2 end of life covers the upgrade.

A checklist for converting a media library

  1. Back up the media library and the database. Keep every original.
  2. Confirm server support for AVIF and WebP on staging and production. The two can differ.
  3. Pick a quality setting by comparing a few real photos and one screenshot side by side.
  4. Turn on conversion through the WordPress filter or plugin, or the Drupal image style effect.
  5. Keep a fallback: WebP or JPEG for photos, PNG for transparency.
  6. Regenerate existing sizes in batches, outside busy hours. Drupal refreshes a style’s images when the style changes.
  7. Check the markup on a few pages: type attributes, an img fallback, width and height, a sensible sizes value.
  8. Test in Safari, Firefox and Chrome on a phone.
  9. Purge the CDN and page cache, then recheck the LCP image in PageSpeed Insights.

Measure before and after. Our Core Web Vitals explainer covers each metric. The guide to fixing INP covers scripts, which image work does not touch.

AVIF vs WebP browser support, as of October 2026

These AVIF vs WebP figures come from caniuse.com in October 2026, using StatCounter data for September 2026.

Format First full support Global share of users
AVIF Chrome 85, Edge 121, Firefox 93, Safari 16.4 (partial in 16.1 to 16.3), iOS Safari 16.0 About 96.4%
WebP Chrome 32, Edge 18, Firefox 65, Safari 16.0 (partial in 14 to 15.6), iOS Safari 14 About 97.2%
JPEG and PNG All browsers All users

The gap is small, but it is not zero. The remaining users are on older browser versions, which is why the fallback stays.

Frequently Asked Questions

AVIF vs WebP: which should I serve first?

AVIF usually makes smaller files at the same visual quality. WebP has been supported longer and is a common fallback. Most sites serve AVIF first with WebP or JPEG as a fallback.

Do I still need JPEG or PNG files?

Yes. Keep originals, and keep a JPEG or PNG in the img tag as the fallback.

Does AVIF vs WebP matter for Core Web Vitals?

It affects the download part of largest contentful paint. Server response and late discovery of the hero image usually matter more.

Do all browsers support AVIF?

All current major browsers do, as of October 2026. caniuse puts support at about 96% of users, so keep a fallback.

Does WordPress convert my JPEGs to AVIF automatically?

No. Core accepts AVIF uploads since 6.5 and WebP since 5.8. Converting JPEG uploads needs the image_editor_output_format filter or a plugin.

How do I convert images I already uploaded to WordPress?

Regenerate them after turning on conversion, with WP-CLI’s wp media regenerate or a regeneration plugin. Do it in batches.

Can Drupal 10 serve AVIF?

Not with core’s new AVIF effect, which arrived in Drupal 11.2. Drupal 10 also reaches end of life on December 9, 2026.

How do I know if my server supports AVIF?

In WordPress, check Media Handling under Site Health, Info. In PHP, gd_info() or imagetypes() shows what GD can write. Your host can confirm Imagick.

Should logos be AVIF or WebP?

Use SVG for logos drawn as vectors. For raster logos, lossless WebP or PNG keeps edges sharp.

Digital Matters

Web Design Desk