Performance and accessibility 4 min read Updated
Where lazy loading helps and where it hurts
In short
Use lazy loading for images and iframes below the first screen, and never for the element that shows first.
Lazy loading tells the browser to postpone images and iframes that the reader has not reached yet. Used well, it saves bandwidth and leaves more of the first screen free for what matters. Used on the wrong element, it delays the very image that decides how fast the page feels. Start by finding the element that matters most on the first screen.
How the loading attribute works
The loading attribute can be set on img, iframe, video and audio elements. With the value lazy, the browser defers loading of the resource until it reaches a calculated distance from the viewport. MDN describes the purpose as deferring resources that are off-screen until the user scrolls near them. The browser calculates the distance itself. web.dev notes that these thresholds are hardcoded and cannot be changed through the API, so the attribute is a sensible default rather than fine-grained control.
Where lazy loading helps
Lazy loading suits content that many visitors never reach. MDN notes that most images on a page are off-screen when it first loads, and that many iframes, videos and audio files are too. Typical candidates are:
- product photos in a long listing, below the first row;
- images in a later section of an article or in the footer;
- maps and video players placed well down the page.
Each of these downloads costs bandwidth and processing time. A visitor who leaves early never needs to spend it, so deferring the file keeps the first screen fast.
Working on something similar in your own product? A few honest sentences are enough – we read every enquiry and reply by email. Apply with your idea
Never lazy-load the LCP image
The most common mistake is to defer the image that decides how fast the page looks. web.dev is direct about this: do not lazy-load images that are likely to be in the viewport when the page loads, especially LCP images. The Largest Contentful Paint is often the hero image or the main product photo, so it belongs in the initial HTML and should load eagerly. The guide on fixing Largest Contentful Paint explains how to find that element.
The load event needs care too. MDN points out that it fires once the eagerly loaded content has finished, and that lazily loaded images inside the visible area may still be loading at that moment. Code that waits for load therefore cannot assume that every image on the screen is ready. The complete property of an image shows whether it has finished loading.
Iframes, video and audio
The same attribute works on iframes, and web.dev reports that the iframe form has also been standardised. A video player placed far down a page is a good candidate: as a lazy iframe, it loads when the reader approaches it rather than with the first screen. MDN’s own example shows a lazy iframe that wraps a video player.
Lazy loading does not replace careful layout. A deferred element still needs room on the page before it arrives. Reserving that room is covered in fixing Cumulative Layout Shift, and the choice of image size is covered in responsive images.
The rules of thumb in this article come from general engineering practice. The statements about the attribute, the load event and the LCP image come from the two cited sources.
A practical checklist
Use the table to decide each element, then work through the list before you release the change.
| Element | Position when the page loads | Attribute |
|---|---|---|
| Header logo | Visible at once | Leave eager |
| Hero or main product photo | Visible at once, often the LCP element | Leave eager |
| Product photos in a long listing | Below the first row | Add lazy |
| Video player near the end of an article | Well below the first screen | Add lazy to the iframe |
- List every img, iframe, video and audio element that carries the attribute.
- On a phone-sized screen, open each main template and find the largest visible element. Make sure it is not lazy-loaded.
- Repeat the check on a desktop screen, because the same image may sit above the fold on one and below it on the other.
- Scroll slowly through each template and confirm that images appear before the reader reaches them.
- Remove the attribute from anything that is visible on load, and keep it only where the saving is clear.
Common questions
- Should every image on a page use lazy loading?
- No. Lazy loading suits images outside the first screen. The image that decides the first paint, often the LCP element, should load eagerly, because web.dev advises against lazy-loading images likely to be in the viewport.
- Does lazy loading also work for iframes?
- Yes. web.dev reports that the iframe form of the loading attribute has also been standardised, and MDN shows it on an iframe that wraps a video player.
- Can a lazily loaded image cause a layout shift?
- The attribute does not reserve space by itself, so the layout should allow for the element before it loads.
Sources
- Browser-level image lazy loading, web.dev. Accessed 24 November 2026
- Lazy loading - Performance | MDN, MDN Web Docs. Accessed 24 November 2026
Further reading
-
Responsive images that fit the screen and the layout
Send each screen a file that matches the space the image occupies, and declare its dimensions so the layout holds while it loads.
-
Text compression with Brotli and gzip
Serve HTML, CSS, JavaScript and SVG compressed with Brotli or gzip, and check the Content-Encoding header on real responses.
-
Fixing Cumulative Layout Shift without jumping content
Give every element its space before it loads, because content that arrives late and pushes the page is the usual cause of layout shift.
Have an idea that should exist? Or a working product that needs more customers, a new website or a complete rework? Bring us anything. Apply with your idea