Free auditStart free
GuideWordPress · Performance

WordPress lazy loading

WordPress adds loading="lazy" itself. See which images it covers, how it protects the LCP image with fetchpriority, and the filters to override it.

4 min
read
4
sources
Oct 29, 2026
updated
Scaplet Editorial Team
author
In one line

Since WordPress 5.5, core adds the native loading="lazy" attribute to images that have width and height attributes. Since 6.3 it also sets fetchpriority="high" on the image it judges most likely to be the LCP image, and never combines the two on one image. You only need to act when a hero image, or a theme template, gets the wrong attribute.

30-second check

Where does your site stand?

Four quick questions, then a straight answer.

1/4Have you checked your own site for this?
Summarize this page withChatGPTClaudePerplexityGoogleAI Mode
02Explained

Why the LCP image must not be lazy

web.dev's caution is direct: don't lazy-load images that are likely to be in the viewport when the page loads, especially LCP images. The browser cannot lazy-load an image until it knows where the image sits on the page, which makes those images load more slowly. web.dev also says loading="eager" does not load an image faster than one with no attribute. To raise priority, use fetchpriority="high".

web.dev adds that an image with loading="lazy" and fetchpriority="high" is still delayed while it is off-screen, and that the combination isn't really necessary. WordPress core is built around the same rule, which is why it detects in-viewport images and drops the lazy attribute from them. Read more in lazy loading and lazy-loaded LCP image.

03Fix it on your stack

Override it where core guesses wrong

Core never overrides an attribute that is already there. If you set loading or fetchpriority before the function runs, WordPress keeps your value. Start with the narrowest tool.
One image from wp_get_attachment_image(): omit the attribute
echo wp_get_attachment_image(
	42,
	'large',
	false,
	array( 'loading' => false ),
);
Turn lazy loading off for template images (wp_get_attachment_image context)
function disable_template_image_lazy_loading( $default, $tag_name, $context ) {
	if ( 'img' === $tag_name && 'wp_get_attachment_image' === $context ) {
		return false;
	}
	return $default;
}
add_filter(
	'wp_lazy_loading_enabled',
	'disable_template_image_lazy_loading',
	10,
	3
);
Let a small LCP image be eligible for fetchpriority high
add_filter(
	'wp_min_priority_img_pixels',
	function( $size ) {
		if ( is_this_the_url_with_the_image() ) {
			return 200 * 200; // Images at least as big as 200x200
		}
		return $size;
	}
);

WordPress recommends passing false rather than "eager" to the wp_img_tag_add_loading_attr filter when you want to disable lazy loading for a content image, so the attribute is omitted altogether. For theme templates, the 5.5 dev note says an image in header.php that is very likely in the initial viewport should skip the loading attribute. The is_this_the_url_with_the_image() call in the size-threshold snippet is the dev note's own placeholder, so replace it with your own check.

04Worth knowing

Gotchas

No dimensions, no lazy attribute

WordPress only adds loading="lazy" when both width and height are present. Images pasted as raw HTML or output by a plugin without dimensions can be loaded eagerly, and web.dev says missing dimensions default to 0 by 0 pixels, which can make a gallery load everything at once.

Back-filling needs the class

Width and height are only added for attachments whose img tag has the wp-image-$id class.

Plugins can change the result

The pre_wp_get_loading_optimization_attributes and wp_get_loading_optimization_attributes filters can alter or short-circuit the output, so a lazy-loading or optimization plugin may disagree with core.

The first three are free

With the 6.3 default threshold of 3, the first content media elements are not lazy-loaded. A hero image placed after several other images can still get loading="lazy".

A browser that doesn't support `loading` ignores it

The 5.5 dev note calls the native attribute a progressive enhancement, and web.dev says unsupported browsers see no negative effect.

05How it works

Check it worked

  1. 1

    List the attributes

    Run curl -s https://example.com/ | grep -o '<img[^>]*>' and look at the first large image. It should have no loading="lazy", and should carry fetchpriority="high" if WordPress picked it as the LCP image.

  2. 2

    Check an image below the fold

    A later image should have loading="lazy" plus width and height. If it has neither, the markup was likely not output through core.

  3. 3

    Watch the network

    In browser DevTools, open the Network tab, filter by Img, and reload without scrolling. Images far below the fold should not load until you scroll near them.

  4. 4

    Try both templates

    Test a post, the home page and an archive. Core counts images per response, so each template can pick a different first image.

Questions

Asked a lot.

3 questions people ask next, answered from the sources on this page.

01Does WordPress lazy load images by default?

Yes. Since 5.5 it adds loading="lazy" to img tags with width and height attributes, in post content, excerpts, text widgets, avatars and wp_get_attachment_image() output.

02How do I disable lazy loading on one WordPress image?

For wp_get_attachment_image(), pass array( 'loading' => false ) as the attributes. For content images, return false from the wp_img_tag_add_loading_attr filter so the attribute is omitted.

03Does WordPress set fetchpriority high automatically?

Since 6.3 it adds fetchpriority="high" to the image it determines is most likely the LCP image. By default an image must be at least 50,000 pixels in width times height to qualify.

Sources · 4

Every fact, linked and dated.

Official docs first. The date is when we last opened each page.
  • wordpress.org
  • web.dev
  1. 01Lazy-loading images in 5.5 | Make WordPress Coremake.wordpress.org · checked 2026-11-01
  2. 02Image performance enhancements in WordPress 6.3 | Make WordPress Coremake.wordpress.org · checked 2026-11-01
  3. 03wp_get_loading_optimization_attributes() | WordPress Developer Resourcesdeveloper.wordpress.org · checked 2026-11-01
  4. 04Browser-level image lazy loading for the web | web.devweb.dev · checked 2026-11-01
Free · 2 minutes

Tools point. Agencies advise. This one ships.

Run the free audit, then approve the fixes. Every change can be undone.

Free, no card60 secondsNobody will call you
  • 46 fixes shipped without a ticket Brightpipe
  • 0→7 ChatGPT citations in six weeks Paylane