DEV Community

Cover image for loading=lazy, counted in bytes: 607.6 KB down to 202.5 KB
Sahadat Husain
Sahadat Husain

Posted on

loading=lazy, counted in bytes: 607.6 KB down to 202.5 KB

On a page with 12 images of 50.6 KB each, Chromium downloaded 607,560 bytes by the load event when every image was eager. With loading="lazy" it downloaded 202,520 bytes on a 390 px phone (4 images) and 151,890 on a 1280 px desktop (3 images). Scrolling to the end brought the total to 607,560 in every case. Lazy loading moves bytes later. It does not remove them.

What does lazy loading change?

MDN says loading="lazy" defers an image until it reaches a calculated distance from the viewport, as the browser defines it. Two details follow. You do not control the distance, and the browser fetches some images below the fold before you scroll.

How I counted

A local page with a heading and 12 <img> tags, each 960 × 538, pointing to the same 50,630-byte JPEG (with a ?n= query so each counts). Between images sits a 900 px block of text, so the images are far apart. The server logs every image response, and Playwright waits for the load event, then 800 ms more.

const s = await serve(pages, { imgDelay: 100 });
await page.goto(s.url + '/lazy-all.html', { waitUntil: 'load' });
await page.waitForTimeout(800);
const atLoad = { n: s.log.length, bytes: s.log.reduce((a, l) => a + l.bytes, 0) };
for (let y = 0; y <= 12 * 1300; y += 300) {
  await page.mouse.wheel(0, 300);
  await page.waitForTimeout(120);
}
await page.waitForTimeout(800);
const total = { n: s.log.length, bytes: s.log.reduce((a, l) => a + l.bytes, 0) };
Enter fullscreen mode Exit fullscreen mode

I ran three pages: all images eager, all lazy, and the first image fetchpriority="high" with the rest lazy. Five runs each. The counts were identical in every run.

What did it save before first paint?

Image bytes at load, eager against lazy, at 390 and 1280 pixels

  • 390 px phone, all eager: 12 images, 607,560 bytes.
  • 390 px phone, all lazy: 4 images, 202,520 bytes. That is 405,040 bytes fewer, 66.7%.
  • 1280 px desktop, all eager: 12 images, 607,560 bytes.
  • 1280 px desktop, all lazy: 3 images, 151,890 bytes. That is 455,670 bytes fewer, 75.0%.
  • After scrolling to the end: 12 images and 607,560 bytes for every page.

The phone fetched one more image than the desktop. Its images are shorter, so more of them sit within the load distance.

Does lazy loading slow the hero image?

A little, in my run. I recorded the Largest Contentful Paint time, median of 5 runs, with the server holding each image for 100 ms:

  • All eager: 112 ms at both widths.
  • All lazy: 120 ms at both widths.
  • Hero fetchpriority="high", rest lazy: 112 ms at both widths.

The 8 ms gap held in all five runs at each width, but this is localhost with a 100 ms delay. On a real network, a lazy hero waits for layout before the request starts, and the gap can be larger. I did not measure that.

Note: Never put loading="lazy" on the image that is the LCP element. The images in view at load should be eager. Only the ones below the fold should be lazy.

What about layout shift?

A lazy image has no height until it loads. Write width and height on every lazy image, as I did here, so the box is reserved. MDN calls the attributes especially important for lazy images because unloaded ones have a size of 0.

Where did the saved bytes come from?

Each image is 50,630 bytes. At 390 px the lazy page deferred 8 of 12 images, which is 8 × 50,630 = 405,040 bytes. At 1280 px it deferred 9, which is 455,670. The saving is the count of deferred images times their size, so it grows with the page. A gallery of 40 such images would defer more. I measured 12 only.

The hero markup I used for the third page:

<img src="p-960.jpg" width="960" height="538" fetchpriority="high" alt="">
<img src="p-960.jpg?n=1" width="960" height="538" loading="lazy" alt="">
Enter fullscreen mode Exit fullscreen mode

What should you do?

  1. Leave the first image or two eager. Add fetchpriority="high" to the hero.
  2. Add loading="lazy" to every image that starts below the fold.
  3. Keep width and height on all of them.
  4. Count your own page: log image requests at the load event, as above. The page image analyzer shows how heavy each image is.

Smaller files help both cases. The Blinkimg API compresses a file before you serve it.

How I measured

  • Apple Silicon Mac, 2026-10-18. Node 24.22.0, Playwright 1.61.1, Chromium 149.0.7827.55.
  • File: p-960.jpg, 50,630 bytes (mozjpeg q80, sharp 0.35.4, from a 4964 × 2782 camera photo). Bytes are response bodies from a server log.
  • Viewports 390 × 844 and 1280 × 800. Median of 5 runs for LCP. Raw output: measured.json.

What I did not test

I did not test Firefox or Safari, whose lazy-loading distances differ. I did not use a throttled network, a CDN or a real page with mixed image sizes.


I build Blinkimg, an image compressor and converter with a developer API. I wrote this article with help from an AI assistant (Claude), which ran the code on my machine; every number in it comes from those runs.

Top comments (0)