Course contentsShow
← Web Development
Lesson 1951 of 2,98236. Performance Optimization TechniquesFree lesson

What is Lazy Loading and Why It Matters

Understanding lazy loading as a performance pattern that defers loading non-critical resources until needed.

What is Lazy Loading and Why It Matters

You'll learn what lazy loading is and why deferring non-critical resources improves performance.

What is Lazy Loading?

Lazy loading is a performance optimization pattern that delays loading resources (images, scripts, components, etc.) until they're actually needed—typically when they're about to enter the user's viewport or when triggered by a user action.

Think of it like a restaurant menu: you don't need to cook every dish as soon as the restaurant opens. Instead, you prepare each meal only when a customer orders it. Similarly, lazy loading doesn't burden the browser with loading everything upfront; it loads resources on-demand.

Why Lazy Loading Matters

When users first visit your page, they only see content "above the fold"—the visible portion of the screen. Loading everything immediately (images far down the page, off-screen components, third-party widgets) wastes bandwidth, slows initial render, and delays interactivity.

Lazy loading addresses multiple performance concerns:

  • Reduces initial page weight: Only critical resources load first
  • Improves Core Web Vitals: Faster LCP and better FID/INP by reducing main thread work
  • Saves bandwidth: Users on mobile or slow connections don't download unseen content
  • Accelerates time-to-interactive: Browser focuses on what's immediately visible

This pattern works hand-in-hand with code splitting (which you've learned): code splitting creates separate chunks, and lazy loading determines when to fetch them.

Common Lazy Loading Targets

  • Images below the fold
  • Third-party embeds (videos, maps, social widgets)
  • JavaScript bundles for routes or features not immediately needed
  • Heavy components or modals that appear conditionally

Key Takeaway: Lazy loading defers loading non-critical resources until needed, dramatically improving initial page load performance and user experience by prioritizing what's immediately visible.