← CodeClarityLab Home
Browse by Category
+ added · updated 7d
← Back to glossary

Lazy Loading Images

frontend Beginner

Also Known As

loading=lazy image lazy load deferred images

TL;DR

Deferring off-screen image downloads with loading="lazy" — improves initial page load and LCP by only fetching images as they approach the viewport.

Explanation

Native lazy loading (loading="lazy" on img and iframe) defers fetching until the resource is near the viewport — supported in all modern browsers since 2020. Combined with Intersection Observer for custom thresholds, lazy loading can reduce initial page weight by 50-80% on image-heavy pages. Key attributes: loading="lazy" (native), decoding="async" (non-blocking decode), fetchpriority="high" for LCP images, and width/height to prevent layout shift. Never lazy-load above-the-fold images — they should load immediately.

Common Misconception

All images should be lazy-loaded for performance — lazy-loading above-the-fold images delays LCP and harms Core Web Vitals; only lazy-load images below the fold.

Why It Matters

A product listing page with 50 images loads all 50 on initial render without lazy loading — with loading=lazy, only the 5 visible images download, reducing initial payload by 90%.

Common Mistakes

  • loading=lazy on hero images — the LCP image must load immediately; never lazy-load it.
  • No width and height attributes — browser cannot reserve space, causing layout shift (CLS).
  • Lazy loading images in CSS background — loading=lazy only works on img elements.
  • Using a JavaScript lazy loader when loading=lazy has full browser support.

Code Examples

✗ Vulnerable
<!-- All images load immediately — wastes bandwidth:
<img src="hero.jpg" loading="lazy">  <!-- Never lazy-load LCP! -->

<!-- Page with 50 product images — all fetch on load:
<img src="product-1.jpg" alt="Product 1">
<img src="product-2.jpg" alt="Product 2">
<!-- ... 48 more -->
✓ Fixed
<!-- LCP image: eager + high priority:
<img src="hero.jpg" alt="Hero" loading="eager" fetchpriority="high"
     width="1200" height="600">

<!-- Below-fold images: lazy + dimensions for CLS prevention:
<img src="product-1.jpg" alt="Product 1" loading="lazy"
     decoding="async" width="300" height="300">
<img src="product-2.jpg" alt="Product 2" loading="lazy"
     decoding="async" width="300" height="300">
<!-- Browser fetches only images near viewport -->

Added 16 Mar 2026
Edited 22 Mar 2026
Views 35
Rate this term
No ratings yet
🤖 AI Guestbook educational data only
| |
Last 30 days
0 pings W 0 pings T 0 pings F 0 pings S 0 pings S 0 pings M 1 ping T 0 pings W 1 ping T 0 pings F 0 pings S 0 pings S 0 pings M 0 pings T 2 pings W 1 ping T 0 pings F 2 pings S 0 pings S 0 pings M 0 pings T 0 pings W 0 pings T 1 ping F 1 ping S 0 pings S 0 pings M 1 ping T 0 pings W 0 pings T
No pings yet today
No pings yesterday
Amazonbot 7 Perplexity 7 Google 5 SEMrush 3 ChatGPT 2 Unknown AI 2 Majestic 1 Qwen 1 Ahrefs 1
crawler 28 crawler_json 1
DEV INTEL Tools & Severity
🟠 High ⚙ Fix effort: Low
⚡ Quick Fix
Add loading='lazy' to all images below the fold — one attribute, zero JavaScript; for the hero/LCP image add fetchpriority='high' and preload it instead
📦 Applies To
any web
🔗 Prerequisites
🔍 Detection Hints
All images loaded eagerly including below-fold; LCP image missing fetchpriority=high; no loading=lazy on images
Auto-detectable: ✓ Yes lighthouse pagespeed-insights
⚠ Related Problems
🤖 AI Agent
Confidence: Medium False Positives: Low ✓ Auto-fixable Fix: Low Context: Line

✓ schema.org compliant