WordPress
wordpress
lazy loading
performance
images
site speed

WordPress Lazy Loading: Images, Videos, and Iframes

Lazy loading defers loading of off-screen content until users scroll near it. This simple technique can dramatically improve initial page load times by reducing the resources needed upfront. WordPress...

Bibin WilsonAuthor
January 23, 2026
5 min read
0 views
Introduction

Lazy loading defers loading of off-screen content until users scroll near it. This simple technique can dramatically improve initial page load times by reducing the resources needed upfront. WordPress includes native lazy loading, but understanding how to optimize it is key to maximum performance.

What Is Lazy Loading?
How It Works

Without Lazy Loading:

  • Browser loads ALL images on page load
  • 50 images = 50 immediate requests
  • Slow initial load

With Lazy Loading:

  • Browser loads only visible images
  • Off-screen images load as user scrolls
  • Fast initial load
Benefits
  • Faster initial page load
  • Reduced bandwidth usage
  • Better Core Web Vitals (LCP)
  • Improved server performance
  • Better mobile experience
Native WordPress Lazy Loading
WordPress 5.5+ Feature

WordPress automatically adds loading="lazy" to images:

<img src="image.jpg" loading="lazy" width="800" height="400">
What It Covers
  • Images in content
  • Featured images
  • Some theme images
Limitations
  • Applies to all images (including above-fold)
  • No iframe support natively
  • Limited configuration
Excluding Above-Fold Images
Why Exclude

Above-fold images should load immediately. Lazy loading them can hurt LCP scores.

Method 1: Plugin Setting

WP Rocket:

  • Automatically excludes first images
  • Configurable threshold
Method 2: Code Filter
// Exclude specific images from lazy loading
add_filter('wp_img_tag_add_loading_attr', function($value, $image, $context) {
    // Exclude images with specific classes
    if (strpos($image, 'no-lazy') !== false) {
        return false;
    }
    // Exclude featured images in single posts
    if ($context === 'the_content' && is_singular()) {
        static $count = 0;
        $count++;
        if ($count <= 1) {
            return false;
        }
    }
    return $value;
}, 10, 3);
Method 3: Manual Attribute

Add loading="eager" to critical images:

<img src="hero.jpg" loading="eager" width="1200" height="600">
Lazy Loading Plugins
WP Rocket

Features:

  • Image lazy loading
  • Iframe/video lazy loading
  • Threshold configuration
  • Excludes first images
  • YouTube facade

Configuration:

  1. Go to Settings > WP Rocket
  2. Media tab
  3. Enable LazyLoad options
Lazy Load by WP Rocket (Free)

Features:

  • Image lazy loading
  • Iframe lazy loading
  • YouTube thumbnails
a3 Lazy Load

Features:

  • Fine-grained control
  • Multiple lazy load effects
  • Exclude by class/ID
  • Mobile-specific settings
Perfmatters

Features:

  • Lazy loading
  • Exclude above-fold
  • Database optimization
  • Script management
Lazy Loading Videos
YouTube Videos

Problem: Embedded YouTube loads heavy resources

Solution: YouTube Facade

Instead of embedding directly, show thumbnail that loads video on click.

WP Rocket:

  • Enable "Replace YouTube iframe with preview image"

Manual Implementation:

<div class="youtube-facade" data-video-id="VIDEO_ID">
    <img src="https://img.youtube.com/vi/VIDEO_ID/maxresdefault.jpg" loading="lazy">
    <button class="play-button">Play</button>
</div>
Self-Hosted Videos

Add loading attribute:

<video loading="lazy" poster="thumbnail.jpg">
    <source src="video.mp4" type="video/mp4">
</video>

Or use preload attribute:

<video preload="none" poster="thumbnail.jpg">
Lazy Loading Iframes
Common Iframes
  • Google Maps
  • YouTube/Vimeo
  • Social media embeds
  • External widgets
Native Support

Browser support for iframe lazy loading:

<iframe src="https://example.com" loading="lazy"></iframe>
Plugin Support

Most lazy loading plugins handle iframes automatically.

Google Maps Optimization

Option 1: Lazy load iframe

<iframe loading="lazy" src="https://maps.google.com/..."></iframe>

Option 2: Static image with link Show static map image, link to full map.

Background Images
The Challenge

CSS background images don't support loading="lazy".

Solutions

Method 1: Convert to img tag Use actual img elements instead of backgrounds when possible.

Method 2: Intersection Observer

const lazyBackgrounds = document.querySelectorAll('.lazy-bg');
const observer = new IntersectionObserver((entries) => {
    entries.forEach(entry => {
        if (entry.isIntersecting) {
            entry.target.classList.add('visible');
            observer.unobserve(entry.target);
        }
    });
});
lazyBackgrounds.forEach(bg => observer.observe(bg));
.lazy-bg {
    background-image: none;
}
.lazy-bg.visible {
    background-image: url('image.jpg');
}
Placeholder Strategies
Types of Placeholders

1. Low Quality Image Placeholder (LQIP)

  • Tiny blurred version
  • Smooth visual transition

2. Dominant Color

  • Single color matching image
  • Clean, minimal

3. Skeleton/Gray Box

  • Simple gray placeholder
  • Fastest loading

4. No Placeholder

  • Native browser behavior
  • Space reserved by dimensions
Implementation

Most plugins use simple placeholders. For LQIP:

  • Generate tiny versions of images
  • Apply blur effect
  • Fade to full image on load
Testing Lazy Loading
Check If Working
  1. Open DevTools > Network
  2. Disable cache
  3. Reload page
  4. Scroll slowly
  5. Watch images load as you scroll
Verify With DevTools
  1. Right-click image > Inspect
  2. Check for loading="lazy" attribute
  3. Verify dimensions present
Performance Testing
  • Before/after speed tests
  • LCP comparison
  • Total requests on initial load
Common Issues
Issue: Lazy loaded images in viewport

Solution: Exclude above-fold images

Issue: CLS from lazy images

Solution: Always include width/height dimensions

Issue: SEO concerns

Solution: Lazy loading doesn't affect SEO negatively. Google can see and crawl lazy loaded images.

Issue: Print/PDF issues

Solution: Some lazy loading can affect printing. Test or add print stylesheet:

@media print {
    img[loading="lazy"] {
        display: block !important;
    }
}
Best Practices
Do
  • Include width and height attributes
  • Lazy load below-fold images
  • Use facades for heavy embeds
  • Test thoroughly after implementation
Don't
  • Lazy load above-fold images
  • Forget image dimensions
  • Over-complicate implementation
  • Ignore mobile testing
Frequently Asked Questions
Does lazy loading affect SEO?

No. Google can crawl and index lazy loaded images. It's a recommended practice.

Should I lazy load everything?

No. Critical above-fold content should load immediately.

Native vs plugin lazy loading?

Native is simpler but less configurable. Plugins offer more control and features.

Does lazy loading work on mobile?

Yes, and it's especially beneficial for mobile due to bandwidth considerations.

Key Takeaways
  • WordPress includes native lazy loading since 5.5
  • Exclude above-fold images from lazy loading
  • Use facades for heavy embeds like YouTube
  • Always include image dimensions
  • Plugins offer more control than native
  • Test after implementation
  • Benefits outweigh any drawbacks
Next Steps

Enable lazy loading with WP Rocket or native WordPress. Test your LCP scores. Implement YouTube facades for video-heavy pages. Check our Image Optimization guide for complementary techniques.


Meta Description: Master WordPress lazy loading for images, videos, and iframes. Learn to implement native lazy loading, use plugins, and optimize for Core Web Vitals.

Keywords: wordpress lazy loading, lazy load images, defer images, performance optimization, page speed

Frequently Asked Questions

Find answers to common questions about this topic

No. Google can crawl and index lazy loaded images. It's a recommended practice.
No. Critical above-fold content should load immediately.
Native is simpler but less configurable. Plugins offer more control and features.
Yes, and it's especially beneficial for mobile due to bandwidth considerations.

Ready to Invest in Premium Domains?

Browse our curated marketplace of high-quality domains and find your perfect investment