Skip to content
BENIBIX Learn

Lazy Loading

Development🌐 Web DevelopmentRendering

Also known as Lazy Load, loading="lazy", Deferred Loading

Pictures and code that load late, just as the reader gets near them.

Think of it like

It is like a waiter who brings each dish just when you want it.

Example

Lucy's photo blog has 60 pictures per page. With lazy loading, only the first few load, and the page opens in a second.

Why it matters

A faster first view keeps readers on the page. People on phones also save data they would never have used.

Definition

Lazy loading means a page waits to load a thing until the reader is about to need it. Pictures far down a long page are not fetched at first. As the reader scrolls near one, the browser fetches it. In HTML, you add loading="lazy" to an image or an iframe. The page shows up sooner and uses less data. The same idea applies to code that a page loads in parts.

Example code

html
<img src="beach.jpg" alt="Waves on a sandy beach" loading="lazy">
The browser fetches this picture only when the reader scrolls near it.
Pictures below the window wait. Each loads as the reader scrolls near it.

Common mistake

Lazy loading the big picture at the top. It then loads late, and the page feels slower, not faster.

Key takeaways

  1. 1
    Load when near. Fetch just before it comes into view.
  2. 2
    Faster first view. The top of the page comes first.
  3. 3
    Not the top picture. Load what is seen at once right away.

Compare