JavaScript 3 min read

Lazy Loading Images and Iframes Explained

Lazy loading delays off-screen images and embeds until they're needed, saving data and speeding up pages. Learn native lazy loading, the one image you must never lazy-load, and how WordPress handles it.

On this page

Key takeaways

  • Lazy loading delays off-screen images and iframes until the user scrolls near them, saving data and speeding up the first load.
  • Use the native loading="lazy" attribute — no JavaScript library needed.
  • Never lazy-load the LCP/hero image; it should load immediately with fetchpriority="high".

A long blog post might contain 20 images, but a visitor sees two or three on the first screen. Without lazy loading, the browser downloads all 20 immediately, competing with the content that matters. Lazy loading fixes that — but used wrongly, it makes your most important image slower.

Native lazy loading#

<img src="chart.webp" alt="Organic traffic growth after technical fixes" width="800" height="450" loading="lazy">
<iframe src="https://www.youtube-nocookie.com/embed/ID" title="Video title" loading="lazy"></iframe>

Supported by all modern browsers. The browser decides when to load based on distance from the viewport and connection speed.

What to lazy-load — and what not to#

Lazy-load Load eagerly
Images further down articles The hero / featured image at the top
Comment avatars, related-post thumbnails The logo
YouTube and map embeds below the fold Any image likely to be the LCP element
Footer images and badges Images in the first screen of mobile layouts
The most common mistake Many plugins lazy-load every image, including the hero. The browser then waits until layout to discover it should load, delaying LCP by hundreds of milliseconds. WordPress core skips lazy-loading the first content images, but plugins and page builders often override that.

Prioritising the LCP image#

<img src="hero.webp" srcset="…" sizes="…" width="1200" height="675"
     alt="…" fetchpriority="high" decoding="async">

If the hero is a CSS background image, the browser discovers it late. Prefer an <img>, or preload it: <link rel="preload" as="image" href="hero.webp" fetchpriority="high">.

Need a hand with this?

Get a quick, honest review of your website’s SEO.

Chat on WhatsApp

Avoid layout shift#

Always set width and height (or CSS aspect-ratio) so the browser reserves space before lazy images load. Otherwise, content jumps as images appear — bad for CLS.

Lazy loading other things#

  • Videos: use a facade — see embedding YouTube and Maps without slowing your site.
  • Background images and sections: IntersectionObserver can add a class when a section approaches the viewport.
  • JavaScript modules: dynamic import() loads code only when a feature is used.
  • Rendering: content-visibility: auto skips rendering of off-screen sections.

SEO considerations#

  • Native lazy loading is fully compatible with Google — images have real src attributes Google can see.
  • Old JavaScript lazy-loaders that use data-src without a noscript fallback can hide images from crawlers.
  • Don’t lazy-load content that requires user interaction (clicks) to appear if you want it indexed.

Lazy loading FAQ#

Does WordPress lazy-load images by default?#

Yes, since WordPress 5.5, with smarter rules since 6.3 that skip the first images and add fetchpriority="high" to the likely LCP image.

Do I still need a lazy-loading plugin?#

Usually not for images. Plugins can still help with video facades and background images.

How do I check whether my hero image is lazy-loaded?#

Inspect the image and look for loading="lazy", or check PageSpeed Insights’ “Largest Contentful Paint image was lazily loaded” warning.

Found this useful? Share it

Join the discussion

Your email address will not be published. Required fields are marked *

Security code image. If you cannot read it, press refresh or contact me on WhatsApp.