Lazy Loading Explained: Complete Guide for 2026
"Learn how lazy loading works and when to use it for website images, iframes, videos and other resources. Understand native lazy loading, Intersection Observer, LCP, CLS, responsive images, SEO, accessibility and common mistakes."
Lazy Loading Explained: Complete Guide
A web page may contain dozens of images, videos, embeds, and other resources—but visitors don't necessarily need all of them the moment the page opens.
Downloading everything immediately can waste bandwidth and compete with the content users actually want to see first.
Lazy loading solves this by delaying certain resources until they're likely to be needed.
Used correctly, it can make the initial page load lighter and faster. Used incorrectly, it can delay important content and hurt performance.
What Is Lazy Loading?
Lazy loading is a technique that postpones loading a resource until it is needed or approaching the user's visible area.
Consider a long article:
Top of Page
├── Hero Image ← Needed immediately
├── Introduction
├── Content
├── Image 2 ← Needed later
├── Content
├── Image 3 ← Needed later
└── Video ← Needed much later
Without lazy loading, the browser may begin downloading all these resources early.
With lazy loading, offscreen resources can wait until the visitor gets closer to them.
Lazy Loading vs Eager Loading
Eager loading means a resource is loaded normally without intentional deferral.
Lazy loading delays eligible resources.
Conceptually:
Eager:
Page Opens → Load Image
Lazy:
Page Opens → Wait → Image Approaches Viewport → Load
Neither approach is always better.
Important above-the-fold content often needs eager loading, while resources far below the fold are strong candidates for lazy loading.
Why Use Lazy Loading?
Lazy loading can reduce unnecessary initial work.
Potential benefits include:
- Smaller initial page transfers
- Fewer immediate network requests
- Reduced bandwidth usage
- Faster initial rendering in appropriate cases
- Less competition for critical resources
Imagine a gallery containing 50 large images.
A visitor may view only the first ten.
Loading all 50 immediately consumes resources for content that user may never see.
Native Lazy Loading for Images
Modern HTML provides a simple way to lazy-load images:
<img
src="product.webp"
loading="lazy"
width="800"
height="600"
alt="Blue backpack">
The important attribute is:
loading="lazy"
The browser decides when to fetch the image based on factors such as its position relative to the viewport.
This is generally preferable to building a custom JavaScript solution when native loading behavior meets your needs.
Don't Lazy-Load Every Image
This is one of the most important rules.
Suppose your page begins with a large hero image:
Header
Hero Image
Headline
Article
If that hero image is the page's Largest Contentful Paint (LCP) element, lazy-loading it may delay when the main visible content appears.
Avoid:
<img
src="hero.webp"
loading="lazy"
alt="Hero image">
for an image that needs to appear immediately.
A more appropriate implementation might be:
<img
src="hero.webp"
width="1200"
height="700"
fetchpriority="high"
alt="Hero image">
Use high priority only when the resource genuinely deserves it.
What Images Should Be Lazy-Loaded?
Good candidates often include:
- Images far below the fold
- Long article illustrations
- Product images further down a listing
- Gallery thumbnails not initially visible
- Related-content images
- Footer graphics
A simple rule is:
Visible soon? Load normally.
Far below the viewport? Consider lazy loading.
Lazy Loading Iframes
Native lazy loading can also be used with iframes:
<iframe
src="embedded-content.html"
loading="lazy"
title="Interactive example">
</iframe>
This can be useful for embeds located far below the initial viewport.
However, the iframe should still have appropriate dimensions or a stable container so it doesn't cause layout shifts when it appears.
Lazy Loading Videos
Videos can be expensive because they may involve large files and additional resources.
One useful approach is to avoid downloading unnecessary video data until required.
HTML provides options such as:
<video
controls
preload="metadata"
poster="video-cover.webp">
<source src="video.mp4" type="video/mp4">
</video>
preload="metadata" suggests that the browser fetch metadata rather than eagerly downloading the entire video.
For heavy third-party video players, another strategy is to initially show a lightweight preview image and create the full player after user interaction.
Conceptually:
Video Thumbnail
↓
User Clicks Play
↓
Load Full Player
↓
Play Video
This can avoid loading a large player that a visitor never uses.
Lazy Loading With Intersection Observer
Sometimes you need behavior beyond native loading="lazy".
JavaScript's Intersection Observer API can detect when an element approaches or enters the viewport.
A simplified example:
const observer = new IntersectionObserver(entries => {
entries.forEach(entry => {
if (!entry.isIntersecting) return;
const image = entry.target;
image.src = image.dataset.src;
observer.unobserve(image);
});
});
document.querySelectorAll("[data-src]")
.forEach(image => observer.observe(image));
HTML:
<img
data-src="photo.webp"
width="800"
height="600"
alt="Mountain landscape">
This approach is useful when you need custom loading behavior.
For ordinary images, native lazy loading is usually simpler.
What About CSS Background Images?
CSS background images don't use the HTML loading attribute.
For example:
.card {
background-image: url("background.webp");
}
If you need conditional loading, you may need a different design or JavaScript-controlled class.
For meaningful content images, consider using <img> or <picture> instead of a CSS background. HTML images provide better semantics and direct support for responsive images, alternative text, and loading attributes.
Lazy Loading and CLS
Lazy loading shouldn't make the page jump when an image appears.
Bad:
<img src="photo.webp" loading="lazy" alt="Photo">
Better:
<img
src="photo.webp"
loading="lazy"
width="800"
height="600"
alt="Photo">
Providing dimensions lets the browser reserve the image's space before it loads.
This helps prevent Cumulative Layout Shift (CLS).
You can also reserve space using CSS techniques such as aspect-ratio.
Lazy Loading and Responsive Images
Lazy loading works well with responsive images:
<img
src="photo-800.webp"
srcset="
photo-400.webp 400w,
photo-800.webp 800w,
photo-1200.webp 1200w"
sizes="100vw"
loading="lazy"
width="1200"
height="800"
alt="Mountain landscape">
These techniques solve different problems:
Responsive images → Choose an appropriate image size
Lazy loading → Decide when the image should load
Using both can reduce unnecessary transfers.
Lazy Loading and SEO
Lazy loading should not make important content dependent on unusual user actions that search systems or other clients may not perform.
For content images, use normal HTML elements and meaningful alt text.
Avoid implementations where essential page content exists only after complicated scrolling or interaction logic.
Lazy loading should optimize delivery, not hide the substance of the page.
Lazy Loading and Accessibility
Lazy loading doesn't replace accessibility practices.
Images still need appropriate alternative text:
<img
src="chart.webp"
loading="lazy"
alt="Chart showing monthly website traffic">
Iframes should have useful titles when appropriate.
Video content may require captions or other accessible alternatives.
Performance and accessibility should work together.
Common Lazy Loading Mistakes
Lazy-Loading the LCP Image
This can delay the most important visible content.
Lazy-Loading Everything
Resources already visible don't benefit from unnecessary deferral.
Forgetting Image Dimensions
Late-loading images can create layout shifts.
Using Heavy JavaScript When Native HTML Works
Don't add unnecessary complexity.
Loading Too Late
If a resource starts loading only after it fully enters the viewport, users may briefly see empty space. Browsers' native implementations can start loading before the resource becomes visible.
Ignoring Mobile Testing
Different viewport sizes change which resources are initially visible.
Practical Lazy-Loading Strategy
A useful page might be configured like this:
LOGO → Normal
HERO / LCP IMAGE → Normal / Prioritized
FIRST CONTENT IMAGE → Depends on position
BELOW-FOLD IMAGES → Lazy
IFRAMES BELOW FOLD → Lazy
VIDEO PLAYER → Lightweight initial load
FOOTER IMAGES → Lazy
Then test rather than assuming the configuration is optimal.
Simple Optimization Workflow
IDENTIFY RESOURCES
↓
IS IT NEEDED IMMEDIATELY?
↙ ↘
YES NO
↓ ↓
LOAD NORMALLY CONSIDER LAZY LOADING
↓ ↓
RESERVE DIMENSIONS
↓
TEST LCP + CLS
↓
TEST ON MOBILE
↓
MEASURE AGAIN
The goal isn't to lazy-load as many resources as possible.
It's to prioritize what visitors need now and postpone what they may need later.
Conclusion
Lazy loading is a straightforward performance technique with one important principle:
Don't make users download resources before they need them.
Use lazy loading for appropriate offscreen images, iframes, videos, and heavy components while keeping important above-the-fold content available immediately.
Remember:
Below-the-fold image → Consider loading="lazy"
LCP image → Usually don't lazy-load
Images → Reserve dimensions
Responsive images → Deliver appropriate sizes
Complex behavior → Consider Intersection Observer
Videos/embeds → Delay heavy resources when appropriate
Used carefully, lazy loading reduces unnecessary initial work without sacrificing visual stability, accessibility, or the speed of important content.
That's what effective lazy loading should accomplish: less work upfront, without making visitors wait for what they actually came to see.
Get a Free Access To 200+ Free Tools:
|
Home Page |
|
|
Calculator Tools |
|
|
Text & Converter Tools |
|
|
PDF & Image Tools |
|
|
Games & Developer Tools |
|
|
Resume Builder |