# Lazy Loading

Lazy loading defers a non-critical resource or feature until it is likely to be needed instead of loading it during the initial experience.

- Type: practice
- Domain: Engineering & architecture
- Level: Intermediate
- Last reviewed: 2026-09-23
- Original: [Soroush’s Product Wiki](<https://wiki.soroush.uk/topic/lazy-loading/>)

## What it means

Lazy loading is a delivery strategy that postpones fetching, decoding, initializing, or rendering work until a later signal such as proximity to the viewport, navigation, or explicit interaction. It can apply to images, frames, code, data, or components. Code splitting creates loadable boundaries; lazy loading decides when to use them.

## Why it matters

Deferring unnecessary work can improve startup speed, data use, memory, and main-thread availability. Deferring the wrong work merely moves latency into a critical interaction and can cause layout shifts or missing content.

## When to use it

Use it for below-the-fold media, uncommon routes, heavy optional tools, or secondary data with a reliable trigger. Load essential content and controls eagerly, and reserve dimensions and meaningful fallbacks for deferred elements.

## How it works

1. Classify resources by whether the initial task truly requires them.
2. Choose a browser feature or application signal that predicts need.
3. Reserve space and provide loading, error, and no-script behavior where necessary.
4. Start work early enough to avoid a user-visible stall but not on every visit.
5. Measure initial savings, later interaction latency, layout stability, and failure rates.

## A practical example

An editorial page loads its lead image normally but marks distant article images for browser lazy loading with dimensions. Readers transfer less data, and reserved space prevents the article from jumping as images arrive.

## Where it breaks

Prediction can be wrong, deferred requests can compete with later critical work, and unsupported or script-dependent strategies need fallbacks. Lazy loading does not reduce the cost for users who eventually load everything.

## Common mistakes

- Lazy-loading the primary image or content needed for the first view.
- Omitting image dimensions and causing layout shifts.
- Triggering loads only after a user reaches an empty placeholder.
- Using scroll listeners when a native attribute or observer is more reliable.

## Visualization

[View the visualization on the website](<https://wiki.soroush.uk/topic/lazy-loading/#visualization-lazy-loading>)

## Sources

1. [Lazy loading](<https://developer.mozilla.org/en-US/docs/Web/Performance/Guides/Lazy_loading>) — MDN Web Docs · Official technical documentation
2. [HTML Standard: Lazy Loading Attributes](<https://html.spec.whatwg.org/multipage/urls-and-fetching.html#lazy-loading-attributes>) — WHATWG · Living web standard

## Related topics

- [Code Splitting](<https://wiki.soroush.uk/topic/code-splitting/>)
- [Critical Rendering Path](<https://wiki.soroush.uk/topic/critical-rendering-path/>)
- [Loading State](<https://wiki.soroush.uk/topic/loading-state/>)
