Performance & Core Web Vitals

Lazy loading in WordPress – images, iframes, video, sections

Text
Table of contents

Lazy loading = loading resources only when they're needed. Instead of downloading 30 images for the whole page, you load just the first 3 (the ones the user sees) and the rest only when they scroll down to them. Less data, faster LCP, better CWV. I'll show you how to do it right in WordPress.

In short

  • WordPress 5.5+ has native lazy loading for images (the attribute loading="lazy").
  • Iframes since version 5.7+, but it only works partially.
  • Video, maps and social embeds require plugins (a3 Lazy Load, WP Rocket).
  • Common mistake: lazy loading the LCP image — this hurts LCP instead of improving it.

What Lazy Loading Actually Does

Without lazy loading, the browser downloads all of the page's resources at once — even the ones you can't see on screen.

A page with 30 images:
– Without lazy loading: 30 × 200 KB = 6 MB downloaded, LCP 4 s
– With lazy loading: 3 × 200 KB = 600 KB downloaded, LCP 1.2 s

The rest of the images load as the user scrolls toward them.

Native Lazy Loading in WordPress

Since version 5.5 (August 2020), WordPress automatically adds the loading="lazy" attribute to every image in post content:

<img src="zdjecie.jpg" loading="lazy" alt="...">

Supported browsers: Chrome, Firefox, Edge, Safari (from 15.4) — 95%+ of users.

Benefits of Native Lazy Loading

  • ✅ Works without a plugin
  • ✅ No JavaScript overhead (a pure browser feature)
  • ✅ Doesn't hurt SEO (Google understands and indexes it)
  • ✅ Also works for iframes (since WP 5.7)

Limitations of Native Lazy Loading

  • ❌ Doesn't work for images added via CSS (background-image)
  • ❌ Doesn't work for video, audio and embeds (e.g. lazy loading the YouTube iframe works, but the YouTube script loads right away)
  • ❌ No control over the threshold (when an image starts loading)
  • ❌ Applies to EVERY image — including the LCP image, which does NOT want it

Pitfall #1: Lazy Loading the LCP Image

The image “above the fold” (the first one visible on the home page) is usually your LCP element. If it has loading="lazy", the browser will delay downloading it until HTML parsing finishes — LCP goes up from 1.2 s to 2.8 s.

Solution

The loading="eager" + fetchpriority="high" attributes for the LCP image:

<img src="hero.webp" loading="eager" fetchpriority="high" alt="...">

In WordPress, the WP Rocket plugin does this automatically (“Exclude from lazy load” for the first 1–2 images).

Without a plugin — a filter in functions.php:

add_filter('wp_lazy_loading_enabled', function($enabled, $tag, $context) {
    if ($context === 'the_post_thumbnail') {
        return false; // disable lazy loading for featured image
    }
    return $enabled;
}, 10, 3);

Lazy Loading for Iframes

WordPress 5.7 added lazy iframes, but only for iframes inserted via the editor — not for embed codes inserted by plugins / Elementor.

YouTube iframe

The default YouTube embed loads 300 KB of JavaScript + thumbnail + player API — even if the user never plays the video.

Solution: replace the iframe with a static thumbnail + play button. The real iframe loads only after it's clicked.

Plugins:
– WP YouTube Lyte (free) — the best
– Lazy Load for Videos (free)
– In WP Rocket: the “LazyLoad for YouTube” option

Real gain: -800 ms LCP if you had 3 videos on the home page.

Google Maps iframe

Google Maps is a huge script + tile server. Each map means 400–800 KB and 20+ requests.

Solution 1: A static map image + an “Open in Google Maps” link.

<a href="https://maps.google.com/?q=Ul.Sadowa,Poznan">
  <img src="static-map.jpg" alt="Mapa">
</a>

Solution 2: A Google Maps iframe with loading="lazy":

<iframe src="..." loading="lazy" width="600" height="400"></iframe>

Lazy loading works, but the Google script still loads heavily once the iframe enters the viewport.

Solution 3: An open-source map (Leaflet + OpenStreetMap) — 90% less code, no Google.

Lazy Loading for Video

<video> HTML5 doesn't support native lazy loading, but you can:

  1. preload="none" — doesn't even fetch metadata
  2. poster="thumbnail.jpg" — show an image, and the video loads after the click
<video preload="none" poster="cover.jpg" controls>
  <source src="video.mp4" type="video/mp4">
</video>

Lazy Loading for Social Embeds

Twitter, Instagram and Facebook embeds load the full SDK libraries (200–500 KB each).

Solution:
– “Lazy embed” plugins — e.g. Disable Comments + manual embed
– Static screenshot + a “View on Twitter” link
– Build-time prerendering — for advanced users: you generate the embed HTML once instead of loading it live

Lazy Loading for CSS background-image

WordPress doesn't handle background-image in CSS. Background images load right away.

Solution 1: Convert backgrounds to <img> with absolute positioning. Sounds hacky, but it works.

Solution 2: The a3 Lazy Load plugin (free) — it also supports background-image.

Solution 3: A custom Intersection Observer in JavaScript (advanced).

Lazy Load Plugins — Which to Choose

a3 Lazy Load (free)

The best free option. Works for:
– Images (extends the native WP feature)
– iframes
– Video
– Background-image in CSS

Minimal JS overhead (3 KB).

WP Rocket (paid, $59/year)

Lazy loading + cache + minify in one. The cleanest all-in-one option.

Smush (free, freemium)

Image optimization + lazy load. Solid, but Smush is "heavy" — it loads a lot of its own JS.

Optimole (freemium)

Lazy load + automatic WebP/AVIF conversion + CDN delivery. Great, but paid for higher traffic.

Lazy Load + Core Web Vitals — How It Works

ElementLazy loadImpact on LCPImpact on CLS
LCP image (hero)❌ NO——
Below-fold images✅ YES+2 sif width/height is missing — it breaks
YouTube iframe✅ YES+1 sif width/height is missing — it breaks
Google Maps✅ YES+0,8 scontainer aspect ratio
Background CSS✅ YES (with a plugin)+0,3 snone

Most common mistakes

❌ Lazy loading the LCP image — it breaks the very thing it was meant to improve.

❌ No width/height on images — lazy loading + missing dimensions = layout shifts, CLS goes up.

❌ Lazy load plugin + native WP — duplicate functionality, sometimes a conflict.

❌ Lazy loading very small images (<5 KB icons) — overhead > gain. Load them eagerly.

❌ Lazy loading for the print stylesheet — printed pages come out with missing images.

What's next

This week:

  1. Open your home page in PageSpeed Insights → mobile
  2. See how many resources are loading (the "Network" tab in DevTools)
  3. Enable native lazy loading + disable it for the LCP
  4. After a week, check the measurement — the difference will be visible

Lazy loading optimization in the speed audit package — we check every image, iframe and embed and set up lazy loading where it makes sense. See the package.

Your feedback

Was this article helpful?

One click — it helps me choose future topics.

Share this article

Websky Newsletter

New posts straight to your inbox.

Once a month — practical insights on WordPress, WooCommerce, SEO and AI. No spam, unsubscribe with one click.

  • Case studies from Polish projects
  • Checklists and templates to download
  • Google and WordPress changes in a nutshell

Your data goes to Websky Studio only. You can unsubscribe with one click in every message.

Core Web Vitals

A slow website is a cost, not a detail.

I'll measure LCP, INP, and CLS on your website, pinpoint the culprits, and show you before/after results. No rebuilding everything from scratch.

Test your site speed