{# canonical_base is the OWNING tenant's origin: all 16 Peasy domains serve the same catalogue, so a page rendered by a non-owner points its canonical at the owner instead of competing with it. Falls back to this site for static/self-owned pages. #}
🍋
Menu
How-To Beginner 2 min read 364 words

Image Lazy Loading: Implementation and Performance Impact

Lazy loading defers off-screen image loading until the user scrolls near them, dramatically improving initial page load time. Learn the native approach, common pitfalls, and how to measure the performance impact.

Key Takeaways

  • Without lazy loading, a browser downloads every image on a page as soon as the HTML is parsed — even images far below the fold that the user may never see.
  • Modern browsers support lazy loading natively with a single attribute:
  • The most common lazy loading mistake is applying it to images visible in the initial viewport.
  • When images are lazy loaded, their space should be reserved to prevent layout shift (CLS).
  • Use Lighthouse or PageSpeed Insights to measure before and after.

What Lazy Loading Does

Without lazy loading, a browser downloads every image on a page as soon as the HTML is parsed — even images far below the fold that the user may never see. On a product listing page with 50 images, this means downloading 20-40 MB of images upfront. Lazy loading tells the browser to only fetch images when they're about to enter the viewport.

Native Lazy Loading

Modern browsers support lazy loading natively with a single attribute:

Product name

Browser support exceeds 95% globally. The browser handles all the complexity — intersection detection, network prioritization, and memory management. No JavaScript required.

Critical Rule: Never Lazy Load Above-the-Fold Images

The most common lazy loading mistake is applying it to images visible in the initial viewport. This delays the Largest Contentful Paint (LCP) metric because the browser deprioritizes the image load. Hero images, logos, and the first row of a product grid should always use loading="eager" (the default) or be explicitly marked with fetchpriority="high".

Identifying Above-the-Fold Content

The fold line varies by device. On desktop (1080px viewport), typically the first 600-700px of content is visible. On mobile (667px viewport), the first 500-550px. A safe rule: the first 1-3 images on a page should not be lazy loaded.

Placeholder Strategies

When images are lazy loaded, their space should be reserved to prevent layout shift (CLS). Set explicit width and height attributes on the tag. The browser uses these to calculate the aspect ratio and reserve space before the image loads.

For a more polished experience, use a low-quality image placeholder (LQIP) — a blurred 20×20 pixel version of the image inlined as a base64 data URL in a CSS background. When the full image loads, it replaces the blur seamlessly.

Measuring Impact

Use Lighthouse or PageSpeed Insights to measure before and after. Key metrics to track:

  • LCP — Should improve unless you accidentally lazy-load the LCP element
  • Total Transfer Size — Initial page load bytes should drop significantly
  • Speed Index — Visual completeness over time should improve
  • CLS — Should remain stable if width/height attributes are set correctly