← Home ← Codex ← DEBT ← Engine
Browse by Category
+ added · ✎ updated 7d
← Back to glossary

Lazy Loading Images

Frontend Beginner
debt(d5/e1/b3/t7)
d5 Detectability Operational debt — how invisible misuse is to your safety net

Closest to 'specialist tool catches it' (d5), because the detection_hints list Lighthouse and PageSpeed Insights — both specialist auditing tools that flag eager-loaded below-fold images and missing fetchpriority on LCP images. This is not caught by a compiler or default linter, but is reliably surfaced by these performance auditing tools.

e1 Effort Remediation debt — work required to fix once spotted

Closest to 'one-line patch or single-call swap' (e1), because the quick_fix is literally adding a single HTML attribute (loading='lazy') to img elements below the fold, and adding fetchpriority='high' to the hero image — both are attribute-level, zero-JavaScript changes.

b3 Burden Structural debt — long-term weight of choosing wrong

Closest to 'localised tax' (b3), because lazy loading decisions apply per-image or per-page-template within the web context. The choice is scoped to frontend image markup; it does not impose a cross-cutting architectural cost on the rest of the codebase, though developers must remember to apply the pattern consistently across image-heavy pages.

t7 Trap Cognitive debt — how counter-intuitive correct behaviour is

Closest to 'serious trap' (t7), because the canonical misconception is that lazy-loading ALL images improves performance — the opposite is true for above-the-fold/LCP images, where loading=lazy actively harms Core Web Vitals. This directly contradicts the intuitive reading of 'lazy loading = good performance everywhere,' and the mistake penalises a visible, user-facing metric (LCP) in a way that contradicts how the attribute behaves on below-fold images.

About DEBT scoring →

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 176
Rate this term
No ratings yet
🤖 AI Guestbook educational data only
| |
Last 30 days
0 pings M 1 ping T 0 pings W 0 pings T 1 ping F 0 pings S 1 ping S 0 pings M 0 pings T 0 pings W 1 ping T 0 pings F 1 ping S 1 ping S 0 pings M 0 pings T 3 pings W 0 pings T 0 pings F 1 ping S 0 pings S 0 pings M 1 ping T 1 ping W 1 ping T 0 pings F 0 pings S 0 pings S 0 pings M 0 pings T
No pings yet today
No pings yesterday
SEMrush 16 Amazonbot 14 Scrapy 14 PetalBot 12 Google 10 Ahrefs 9 ChatGPT 8 Perplexity 7 Bing 5 Claude 3 Twitter/X 3 Majestic 2 Unknown AI 2 Brave Search 2 Applebot 2 Qwen 1 Meta AI 1
crawler 106 crawler_json 5
🧱 FUNDAMENTALS — new to this? Start with the ground floor.
Frontend frontend The frontend is the part of a website or application that users see and interact with directly in their browser—buttons, text, images, and forms.

Every user interaction starts at the frontend. Understanding this layer helps you build interfaces people actually want to use and debug issues that only appear in the browser.

💡 If you can see it or click it, it's frontend; if it stores data or makes decisions you shouldn't expose, that belongs on the backend.

Ask Codex about Frontend →
⚡ 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