# Fix native lazy loading not working for images

URL: https://wp24x7.com/how-to-fix-native-lazy-loading-of-iframe-or-image-not-working/
Updated: 2026-11-29
Type: blog post

> If loading=lazy seems ignored on WordPress images or iframes, the attribute is usually working as designed, the image sits near the top of the page, a plugin is fighting it or the markup lacks width and height. This guide gives a nine-point checklist, a proper DevTools test, code to keep the main image eager and notes on SEO and speed.

## Key facts

- For: owners and developers whose lazy loading does not seem to work
- Common causes: image near the top, missing width and height, a second lazy loader, background images
- WordPress adds loading=lazy to images since 5.5 and iframes since 5.7
- Since 5.9 core skips the first content image
- Test: DevTools Network tab, Img filter, reload at the top, then scroll
- Rule: eager for what visitors see first, lazy for the rest
- Help: speed optimization and support

You added `loading="lazy"` and the browser still downloads everything at once. **Usually the attribute is working as designed, an image sits near the top of the page, a plugin is fighting it, or the markup lacks width and height so the browser cannot reserve space.** Work through the checks below before changing anything.

> **Quick answer**
Check that the image is below the fold, has width and height, and is not handled by a second lazy loader. Keep the main image eager.

Back up and test changes on staging. Use a child theme or a small plugin for code.

## Which cause fits which symptom?

| Symptom | Likely cause |
|:--|:--|
| First image not lazy | By design since WordPress 5.9 |
| Everything loads at once on a short page | Images inside the browser's distance threshold |
| Images load twice or never | A second lazy loader swapping `src` |
| Layout jumps as images appear | Missing width and height |
| Background image still loads | The attribute is not supported there |
| Embed still loads at once | Created by JavaScript, no attribute |

## What does native lazy loading do?

The `loading="lazy"` attribute tells the browser to postpone fetching an image or iframe until it is near the visible area. It saves bandwidth for content that visitors never scroll to. Browsers decide the distance themselves, and it can be large on fast connections, so images a few screens down may still load early. That is normal and not a bug.

WordPress adds `loading="lazy"` automatically to images (since 5.5) and iframes (since 5.7) it prints through core functions, such as post content and `wp_get_attachment_image()`. Since 5.9, core skips the attribute for the first content image, and in later releases it also marks the likely largest image with `fetchpriority="high"`, because lazy loading the main image makes the page feel slower.

## Why is it not working? A checklist

1. **The image is near the top.** Anything in the first screen loads immediately. Test with an image far below the fold.
2. **Missing width and height.** Without them the browser cannot reserve space, so images may load early or shift the layout when they appear. WordPress adds dimensions for media-library images. Hard-coded theme images, images in custom HTML and third-party embeds often lack them. Add them:

```html
<img src="photo.jpg" width="800" height="450" alt="Describe the image" loading="lazy">
```

The numbers are the image's intrinsic size, and CSS (`max-width: 100%; height: auto;`) still makes it responsive.

3. **A plugin or theme uses its own lazy loader.** JavaScript libraries that swap `src` for `data-src` can conflict with native loading, so images may load late, never, or twice. Run only one method. Disable native loading for those images, or disable the plugin's lazy load, not both.
4. **An optimisation plugin strips or rewrites the attribute.** Check your caching or image plugin's lazy loading and "exclude" settings, and view the page source (not the inspected DOM) to see what the server actually sends.
5. **The element is not an image or iframe.** CSS background images do not support the attribute. Use an `<img>`, or an Intersection Observer script, for those.
6. **JavaScript is off or blocked.** Chrome loads images eagerly when scripting is disabled, as a privacy measure.
7. **The browser does not support it.** Today that is very rare. Unsupported browsers just ignore the attribute and load normally.
8. **The image is within the browser's threshold.** Chrome loads lazy images some distance before they scroll into view. A short page can have all images inside that distance.
9. **Iframes added by scripts.** A YouTube or map embed created by JavaScript, rather than printed as an `<iframe>`, has no attribute. Use the plugin's own setting or a facade that loads the real embed on click.

_Eager for what visitors see first, lazy for the rest_

## Which attribute values matter?

| Attribute | Value | Use for |
|:--|:--|:--|
| `loading` | `lazy` | Images and iframes below the fold |
| `loading` | `eager` | The main image the visitor sees first |
| `fetchpriority` | `high` | The likely largest image in the first screen |
| `width` and `height` | Intrinsic size | Every image, so space is reserved |

## How do I test it properly?

1. **Open** the page in a private window with the browser's DevTools.
2. **Go to** the **Network** tab, tick **Disable cache** and filter by **Img** (or **Doc** for iframes).
3. **Reload** at the very top of the page, without scrolling.
4. **Note** which images are requested. Scroll slowly and watch new requests appear for images lower down.

Also look at the **Performance insights** or Lighthouse's "Defer offscreen images" and "Largest Contentful Paint image was lazily loaded" audits. The second one tells you the opposite problem exists: the main image is lazy, so it loads later than it should.

## How do I stop lazy loading on the important image?

The largest image in the first screen, often a hero or featured image, should load at once.

### One image
In your template, pass attributes when printing it:

```php
echo wp_get_attachment_image(
	$attachment_id,
	'large',
	false,
	array(
		'loading'       => 'eager',
		'fetchpriority' => 'high',
	)
);
```

### Whole context
To turn lazy loading off for a whole context, WordPress provides the `wp_lazy_loading_enabled` filter:

```php
add_filter( 'wp_lazy_loading_enabled', function ( $default, $tag_name, $context ) {
	if ( 'img' === $tag_name && 'the_post_thumbnail' === $context ) {
		return false;
	}
	return $default;
}, 10, 3 );
```

Think before disabling it widely, because lazy loading below the fold remains useful. The goal is: eager for what the visitor sees first, lazy for the rest.

## How do I add it to images WordPress does not touch?

For images printed by a theme or custom HTML, add the attributes yourself in the template, as above. For images inside content that skipped the filters, such as a text widget, core's functions may not apply it, so edit the markup directly or use a trusted plugin's setting. Avoid regex tricks on the whole page output, which can break scripts and inline data.

## Does lazy loading hurt SEO?

Native lazy loading is understood by Google's crawler, which renders pages and loads images. Problems appear with JavaScript-only loaders that never put the real `src` into the page. Use the native attribute where you can, and check key pages in the URL Inspection tool in Search Console.

## What else matters for speed?

Right-sized, compressed images and modern formats help more than any attribute. See [serving WebP images with Nginx and EWWW](/webp-images-in-runcloud-nginx-ewww). If your pages still feel slow after these checks, our [WordPress speed optimization](/wordpress-speed-optimization) service profiles the page and fixes the largest causes, and our [support team](/wordpress-support) can help with plugin conflicts.

- **Speed optimization** We profile the page and fix the largest causes. [Read more](/wordpress-speed-optimization)
- **WordPress support** Help with plugin conflicts. [Read more](/wordpress-support)

**Pages still slow?**
Tell us which pages and a person will measure before quoting.
[Free site check](/site-check)
[Post a project](/post-project)

## Frequently asked questions

### Why does lazy loading not work on the first image on my page?

It should not. Images visible without scrolling must load at once, and since WordPress 5.9 core deliberately leaves the loading attribute off the first content image to protect load speed.

### Do iframes support native lazy loading?

Yes, via loading="lazy" in modern browsers, and WordPress adds it to iframes since 5.7. Embeds produced by plugins or scripts may not carry it.

### How can I tell if an image is lazy-loaded?

Open DevTools, the Network tab, filter by Img, reload at the top of the page, and see whether images far down only appear in the list after you scroll.

### Why is lazy loading not applied to my first image?

It should not be. Images visible without scrolling must load at once, and since WordPress 5.9 core leaves the loading attribute off the first content image to protect load speed.

### Why do images a few screens down still load early?

Browsers decide the distance themselves, and it can be large on fast connections, so images a few screens down may load early. That is normal and not a bug.

### Why do width and height matter?

Without them the browser cannot reserve space, so images may load early or shift the layout when they appear. WordPress adds dimensions for media-library images, but hard-coded images, custom HTML and embeds often lack them.

### Can two lazy loaders conflict?

Yes. JavaScript libraries that swap src for data-src can conflict with native loading, so images load late, never or twice. Run only one method.

### Does native lazy loading work on CSS background images?

No. The attribute is for img and iframe elements. Use an img element or an Intersection Observer script for background images.

### How do I test lazy loading properly?

Open DevTools in a private window, go to Network, tick Disable cache, filter by Img, reload at the top without scrolling, note requests, then scroll slowly and watch new requests appear for lower images.

### How do I stop lazy loading on the main hero image?

Print it with loading set to eager and fetchpriority set to high, for example through wp_get_attachment_image attributes. For a whole context use the wp_lazy_loading_enabled filter, but think before disabling it widely.

### Does lazy loading hurt SEO?

Native lazy loading is understood by Google's crawler. Problems appear with JavaScript-only loaders that never put the real src into the page. Check key pages in the URL Inspection tool in Search Console.

### Why does a YouTube embed not lazy load?

An embed created by JavaScript rather than printed as an iframe has no attribute. Use the plugin's own setting or a facade that loads the real embed on click.

### What else helps speed more than an attribute?

Right-sized, compressed images and modern formats help more than any attribute. If pages still feel slow after these checks, speed optimization profiles the page and fixes the largest causes.
