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

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
- Responsive images (since 4.4): images in content get
srcsetandsizesattributes, so a phone downloads a smaller version than a large screen. - Big image scaling (since 5.3): uploads wider or taller than 2560 pixels get a "-scaled" copy that is used as the largest size, while the original is kept on the server.
- Native lazy loading (since 5.5):
loading="lazy"is added to images that have width and height attributes, so the browser waits until they approach the screen before fetching them. - Smarter exceptions (5.9 to 6.3): the first images likely to be visible on load are no longer lazy-loaded, because delaying them slows the page down.
- A priority hint (since 6.3): WordPress adds
fetchpriority="high"to the image it judges most likely to be the page's largest visible element, the "LCP image" measured by Core Web Vitals.
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:
- 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.
- Ask WordPress to write the resized versions in another format. Since 5.8, the
image_editor_output_formatfilter 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. - 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
- Images without dimensions. WordPress only lazy-loads images that carry width and height, and missing dimensions also make the layout jump as pictures arrive. Images inserted through the editor have them; images hard-coded in a theme or pasted as HTML often do not.
- Lazy-loading the main image. A slider, a page builder or an old plugin that forces
loading="lazy"on the header image delays exactly the picture the reader sees first. Check the page source of your home page: the first large image should not be lazy, and ideally carriesfetchpriority="high". - Background images in CSS. A hero picture set as a CSS background escapes
srcset, lazy loading and the priority hint. If it matters, an ordinary image block usually performs better. - Uploading what you don't need. A 6000-pixel photo is still stored in full, even with the 2560-pixel scaling. Resize before uploading when you can.
- Forgetting the text. A faster image still needs alternative text and, when useful, a caption. Our guides to image captions and accessible themes cover both.
A short checklist
- Run a current WordPress version, so the lazy-loading fixes and the priority hint are in place.
- Open Site Health > Info > Media Handling and note which formats your server supports.
- Decide on one route to modern formats: export before upload, the output-format filter, or a plugin. Not two at once.
- Remove any plugin whose only job was lazy loading.
- Look at the source of your home page and one article: dimensions present, first image not lazy, the rest lazy.
- 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.
Thumbnail and image sizes
Which image sizes WordPress creates on upload, how to change thumbnail dimensions, register custom sizes, regenerate existing images and avoid wasted disk space.
Pages & imagesImage captions
How captions work in WordPress: caption versus alt text, adding captions in the Image block and Media Library, styling them, and showing captions in templates.
Pages & imagesAccessible themes
Skip links, focus styles, contrast and reflow: what the accessibility-ready tag requires, and a test you can run in 20 minutes.