Guide

WebP and AVIF in WordPress: a practical guide

Modern image formats can halve your page weight. Here is how they compare, how browsers pick them, and how to use them without a CDN.

Images are usually the heaviest part of a page. Switching from JPEG and PNG to modern formats is one of the simplest ways to make pages lighter—often with no visible difference.

WebP vs AVIF

WebPAVIF
Typical saving vs JPEGAbout 25–35%About 40–50%, sometimes more
Browser supportAll modern browsersAll current major browsers
Encoding speedFastSlower—better done once, in the background
TransparencyYesYes

The best setup serves AVIF where the browser accepts it, WebP otherwise, and the original as a final fallback.

How browsers choose

Use a <picture> element with <source type="image/avif"> and <source type="image/webp"> before the original <img>. Each browser picks the first format it supports. Keep srcset and sizes on every source so phones get small files.

Does WordPress do this already?

WordPress accepts WebP and AVIF uploads, and with a code filter or Google’s Performance Lab plugin it can create modern-format copies of new uploads. It doesn’t convert the images you already have, or offer both formats with a fallback. Most sites use a plugin or a CDN for that.

Converting on your own server

You don’t need an image CDN. If your PHP has GD or Imagick with WebP/AVIF support (most hosts do), images can be converted in the background in small batches, without slowing the site down. Keep the originals, so you can always go back.

Don’t forget the basics

  • Never lazy-load the hero image; preload it.
  • Set width and height to prevent layout shifts.
  • Don’t upload 4000-pixel photos for 800-pixel slots.

With FastFront

FastFront converts your images to WebP and AVIF on your own server in the background, serves them with fallbacks through <picture>, sizes them per device, lazy-loads images below the fold and preloads the hero with a blurred preview. Your originals are never changed.

More speed guides

Not using FastFront yet?

See your own site’s score next to an optimized copy—free, in about a minute.