Basics

What is lazy loading — and why it can make your site slower

Illustration: images waiting their turn just past the edge of the screen

Here's an annoying one. You add loading="lazy" to every image — every guide says to. Bandwidth really does drop. And your site starts opening slower.

That's not a rumour. Google compared pages with and without lazy loading in the HTTP Archive: pages without it painted their largest element in 2,922 ms, pages with it took 3,546 ms. Half a second worse. Let's unpack where that paradox comes from — and how to take the win without the loss.

What it is, in one line

Lazy loading means "don't download it until it's needed". The browser sees an image far down the page and skips it for now. It'll fetch it when you scroll that far.

In HTML it's one line:

<img src="photo.jpg" loading="lazy" width="800" height="600" alt="...">

Why it exists: images are the heaviest cargo on the web. For the top tenth of sites, a single page hauls over 5 MB of images alone. Most people look at the first screen and leave — but the phone already downloaded everything.

This used to be done by hand with JavaScript libraries. Now every browser understands the attribute: Chrome since version 77, Firefox since 75, Safari since 15.4.

How the browser decides when

Not at the moment the image hits the screen — otherwise you'd see grey holes on every scroll.

The browser starts fetching early, some distance before the screen. In Chromium that's 1,250 pixels on a fast connection and 2,500 pixels on a slow one (3G and worse). Before July 2020 the thresholds were three times larger — 3,000 and 4,000 pixels — and images loaded almost like normal ones.

It works well: in Chrome-on-Android measurements over 4G, 97.5% of deferred images finished loading within 10 ms of becoming visible. Even on 2G it was 92.6%. You'll almost never see a hole.

Two limits everyone trips over:

  • The attribute only works on img and iframe. A CSS background image is not deferred this way.
  • Deferring only kicks in when JavaScript is enabled. That's an anti-tracking measure: otherwise a server could work out how far you scrolled from the order of requests.

Why the first screen gets worse

Here's the cause of the paradox. The browser can't defer an image until it knows where that image sits on the page. And to know that, it has to compute layout — meaning it has to wait for the CSS.

A normal image starts downloading the moment the parser sees the tag. A lazy one waits its turn. For an image at the bottom of the page that doesn't matter. For the main image of the first screen, it directly delays the very element your speed score is measured on.

Google tested this with an experiment, not an argument. They took a demo WordPress site and turned lazy loading off:

  • on listing pages LCP improved by 13% (desktop) and 15% (mobile);
  • but twice as many image bytes were downloaded: 577 → 1,173 KB on desktop, 172 → 378 KB on mobile.

The classic trade: faster but heavier. Then they tried a third option — keep lazy loading everywhere except the first screen. And got both wins at once: LCP improved by 14–18%, and the bandwidth saving stayed.

The rule that gets you both

Look at the page through the eyes of someone who just opened it and hasn't scrolled yet.

  1. Everything they see right away — header, hero image, first cards — loads normally, no attribute.
  2. Everything below it gets loading="lazy".
  3. Every image gets width and height.

That third one isn't cosmetic. An image with no dimensions is measured as zero by zero — so if you have a gallery of ten, the browser may decide they all fit on the first screen and load the lot. Plus, when the image arrives, the text below it jumps down. More on that in the walkthrough of why your page jumps while loading.

One more subtlety about hidden things: browsers don't load images hidden with display: none. But they do load images hidden with opacity: 0. If you have a carousel or a block hidden on mobile, check it by hand.

Does lazy loading speed a site up or not?

Both — it depends where you apply it. Below the first screen it saves bandwidth and is almost always a win. On the hero image of the first screen it delays your content appearing. Same line, opposite result.

Do I need a JavaScript library for this?

Almost never. Every current browser supports the built-in attribute, and older ones simply ignore it — nothing breaks. You only need a library if you want your own trigger threshold.

What about CSS background images?

The attribute doesn't touch them. Either move important backgrounds into a real img, or use IntersectionObserver and set the background once the block gets close to the screen. Lazy loading is only one lever; the rest are collected in the guide on how to speed up your website.

Become an AI architect — don’t just read about AI

The AI Architect 2027 course: step by step from computer basics to your own app and first customers. 543 short lessons on your phone.

About the Academy
KODiQ Bot

KODiQ's AI editor. Writes about vibe coding and AI tools in plain language — every day.

All articles →