Pages & images

Faster images in WordPress: WebP, AVIF, lazy loading and fetchpriority explained

Pages & images · · Published 2026-11-14

A young woman in a dark hat sitting on a sofa, looking down at the screen of a digital camera held in her hands
Choosing the pictures happens on the camera. Choosing how they reach the reader happens in WordPress.

On most WordPress pages, images are the heaviest thing the browser downloads. A few years ago the usual answer was a stack of optimisation plugins. Today WordPress itself handles much of the job: it accepts modern formats, lazy-loads images further down the page and tells the browser which picture matters most. What it cannot do is choose your formats, check your server or stop a theme from undoing its work. This guide sets out what core does on its own, version by version, and what is left for you to decide.

If you have not yet looked at how WordPress resizes uploads, start with our guide to thumbnail and image sizes: everything below applies to the files it describes.

What WordPress does without being asked

The WordPress 6.3 developer note explains the last two points. In short, the aim is that the main image arrives as early as possible and everything below the fold waits its turn. None of this needs a plugin, and an old optimisation plugin that adds its own lazy loading on top can now do more harm than good.

WebP and AVIF: supported, but not automatic

WordPress 5.8 added support for uploading WebP images, and WordPress 6.5 did the same for AVIF. Both formats compress much better than JPEG for the same visual quality, and both are supported by current versions of the major browsers. Once uploaded, they behave like any other image: resized versions, srcset, lazy loading and the priority hint all apply.

The catch is the server. WordPress does not convert images itself; it relies on the image library installed with PHP, either Imagick or GD, and that library must support the format. To check, go to Tools > Site Health, open the Info tab and expand Media Handling: the list of supported formats should include WebP and, for AVIF, AVIF. If it does not, uploading such a file fails with an error, and the fix is on the hosting side, usually a newer PHP version or image library.

Two smaller limits are worth knowing. The 5.8 announcement notes that lossless WebP was only supported with Imagick at the time, and that animated or transparent WebP uploads produced ordinary lossy resized versions. If you rely on either, test before converting a whole library.

Turning JPEG uploads into WebP or AVIF

By default, a JPEG upload produces JPEG resized versions. You have three ways to serve a modern format instead:

  1. Export in the new format before uploading. Most image editors can save WebP or AVIF, and so can free tools such as Squoosh. This is the simplest option for a small site that adds a few pictures a week.
  2. Ask WordPress to write the resized versions in another format. Since 5.8, the image_editor_output_format filter maps an upload type to an output type. A few lines in a small site-specific plugin are enough:
    add_filter( 'image_editor_output_format', function ( $formats ) {
        $formats['image/jpeg'] = 'image/webp';
        return $formats;
    } );
    It only affects images uploaded after the change; existing files stay as they are until you regenerate them, as explained in our guide to image sizes.
  3. Use a conversion plugin or your host's image service. These convert the existing library and may serve the new format only to browsers that accept it. Check what happens if you deactivate the plugin: some rewrite URLs in your content, others leave the originals untouched.

Whatever you choose, keep a backup of the uploads folder before a bulk conversion. It is the one part of a WordPress site that cannot be rebuilt from the database.

Compression quality

WordPress applies a default quality setting when it creates resized versions, and developers can change it per format with the wp_editor_set_quality filter, which receives the image type. The 6.5 AVIF note gives the example of setting a quality of 75 for AVIF only, and explains that a quality of 100 switches AVIF to lossless mode. Lower values give smaller files with more visible artefacts; the right number depends on your photographs, so compare a few at actual size before changing anything site-wide.

Mistakes that make pages slower

A short checklist

  1. Run a current WordPress version, so the lazy-loading fixes and the priority hint are in place.
  2. Open Site Health > Info > Media Handling and note which formats your server supports.
  3. Decide on one route to modern formats: export before upload, the output-format filter, or a plugin. Not two at once.
  4. Remove any plugin whose only job was lazy loading.
  5. Look at the source of your home page and one article: dimensions present, first image not lazy, the rest lazy.
  6. Back up the uploads folder before any bulk conversion or regeneration.

Done once, this is rarely worth revisiting more than once a year. The biggest gains on most small sites come from the first two items on the list and from resizing photographs before they ever reach the Media Library.