Lazy Loading
Lazy loading defers loading images, iframes and other resources until they are about to enter the viewport, speeding up initial page load and saving data.
What is Lazy Loading?
Lazy loading is a web performance technique that defers loading non-critical resources, such as images, iframes and videos below the fold, until they are about to enter the user’s viewport. The page renders its visible content faster, uses less bandwidth, and only fetches the rest if the user scrolls far enough to need it.
Modern browsers support lazy loading natively through the loading="lazy" attribute on <img> and <iframe> elements, so most sites no longer need a JavaScript library. For content-heavy B2B SaaS pages with screenshots, diagrams and embedded videos, it can significantly reduce initial page weight.
How it works
- The browser parses the HTML and finds images marked
loading="lazy". - It skips fetching those that are far from the viewport.
- As the user scrolls, the browser requests each image shortly before it becomes visible.
- Images above the fold, or marked
loading="eager"(the default), load immediately.
A minimal example:
<img src="architecture-diagram.png" alt="Zero trust architecture diagram" width="800" height="450" loading="lazy">
Always include width and height so the browser reserves space and avoids layout shift.
Examples
- A cybersecurity vendor’s product page has 15 screenshots. Lazy loading those below the fold means the browser downloads only the first few on load.
- A documentation site embeds YouTube videos via iframes with
loading="lazy", avoiding heavy third-party scripts until a reader reaches them. - A team lazy loads every image including the hero banner and sees LCP get worse. Removing lazy loading from the hero fixes it.
Best practices
- Use native
loading="lazy"for offscreen images and iframes. - Load the LCP image eagerly, and consider
fetchpriority="high"for it. - Set explicit dimensions to prevent Cumulative Layout Shift (CLS).
- If using JavaScript lazy loading, trigger loads with IntersectionObserver, not scroll events or clicks.
- Keep image
srcorsrcsetin the HTML so crawlers can discover image URLs. - Check rendered HTML with Search Console’s URL Inspection tool.
Common mistakes
- Lazy loading above-the-fold content, which harms LCP.
- Hiding primary text content behind “load more” interactions that Googlebot will not trigger.
- Missing width and height attributes, causing layout shifts.
- Using placeholder images without the real URL in markup, so image search cannot index them.
Lazy loading and AI search
AI crawlers vary in how much JavaScript they execute, and many fetch only the raw HTML. Text that appears only after JavaScript-driven lazy loading may be invisible to them. Keep important text in the initial HTML and reserve lazy loading for media, so both search and AI crawlers see the content that should be cited.
Related terms
Sources
- Fix lazy-loaded content, Google Search Central
- Browser-level image lazy loading for the web, web.dev
- The performance effects of too much lazy loading, web.dev
- Lazy loading, MDN
Frequently asked questions
Is lazy loading good for SEO?
Yes, when implemented correctly. It reduces initial page weight and can improve Core Web Vitals. Google can index lazy-loaded content as long as it loads when it enters the viewport, without needing user actions like clicks or scrolling events that Googlebot does not perform. Native loading="lazy" is the safest method.
Should I lazy load the hero image?
No. The hero or largest above-the-fold image is often the Largest Contentful Paint element. Lazy loading it makes the browser wait before requesting it, which delays LCP. Load it eagerly, and consider fetchpriority="high" for the LCP image. Lazy load only images further down the page.
Can Google see content that is lazy loaded with JavaScript?
It can if the content loads when it becomes visible in the viewport, for example using the IntersectionObserver API. Content that loads only after a click, a swipe or a scroll event listener may not be seen. Use the URL Inspection tool to check the rendered HTML.