Web development

Lazy-load images below the initial viewport

Add loading lazy to noncritical images farther down a page. Keep important initial content, such as a prominent first image, immediately discoverable and reserve space with dimensions.

Worked example

HTML example · save as example.html and open in a browser

<p>Article content before the illustration.</p>
<img src="diagram.png" loading="lazy" width="800" height="450"
  alt="A request passes through validation before reaching storage."
  style="max-width:100%;height:auto">

How it works

The browser can defer fetching until the image approaches the visible area. Explicit width and height establish an aspect ratio so text is less likely to shift when the image arrives. The browser determines the precise loading threshold.

Limits and mistakes

Do not add lazy loading indiscriminately to the page’s likely largest visible image. Lazy loading is a browser hint, not an exact scroll-trigger contract. Replace the sample path and verify behavior with a real page and image.

Check the result

Inspect the network panel while loading and scrolling the page. Confirm the image is eventually requested, the alternative remains meaningful, and the reserved space prevents an avoidable layout jump.

Sources

Reference documentation for the behavior used in this guide: