loading="lazy" on the hero image
- Result
- Worse LCP
- Fix
- Remove it; leave the default eager
How to lazy load images and iframes with loading="lazy", when it hurts LCP, how Google sees lazy content, and how to split JavaScript.
Lazy loading defers non-critical resources until they are needed. For images and iframes, add loading="lazy" and the browser waits until they are near the viewport. Never lazy load images that are likely visible on first load, especially the LCP image, because web.dev found it delays Largest Contentful Paint.
Four quick questions, then a straight answer.
From your answers, this is quietly costing you traffic and nobody has the hours to chase it. Scaplet finds every affected page, drafts the fixes and tracks how AI answers mention you.
A data platform shipped 46 fixes without a ticket.
This looks handled. Re-check after a redesign, a migration or a big content push; that is when it breaks.
Your site is small and you have the time. Work through the steps on this page, starting with the pages that get the most traffic.
loading attribute also works on <video> and <audio> elements. JavaScript can be lazy loaded too, through code splitting.The native way is the loading attribute. lazy defers loading until the resource reaches a calculated distance from the viewport. eager is the default and loads it regardless. web.dev says the attribute works only on <img> tags, not on CSS background images.
web.dev's rule: "Don't lazy-load images that are likely to be in-viewport when the page loads, especially LCP images." Its HTTP Archive data shows sites using lazy loading tend to have worse LCP, though that is correlational. In its WordPress A/B test, disabling lazy loading improved median LCP by 13% on desktop archive pages and 15% on mobile archive pages, while single pages changed within normal variance. It concludes that eagerly loading images in the initial viewport and lazy loading the rest gives fewer bytes loaded and improved Core Web Vitals.
Set width and height on every image. web.dev notes that without them images default to 0x0 pixels before loading, which can cause layout shifts and make the browser load many images at once.
<!-- Visible on load: leave eager (the default) -->
<img src="hero.jpg" width="1200" height="630" alt="Dashboard overview">
<!-- Below the fold: defer -->
<img src="gallery-1.jpg" width="800" height="450" alt="Gallery photo" loading="lazy">
<iframe src="https://example.com/embed" width="560" height="315" title="Demo video" loading="lazy"></iframe>MDN says code can be split into smaller chunks, with the rest loaded on demand, and lists dynamic splitting with import() expressions as one approach:
const button = document.getElementById('chat');
button.addEventListener('click', async () => {
const { initChat } = await import('./chat.js');
initChat();
});MDN says this sends the minimal code required to provide value upfront, which improves page-load times. Advice, not from the sources: do not lazy load code the first render depends on.
Google warns that lazy loading done incorrectly can inadvertently hide content from Google, and that content which depends on user actions such as scrolling or clicking is not safe, because Google Search does not interact with your page. To check, run URL Inspection in Search Console and confirm in the rendered HTML that the image src attributes are present.
loading="lazy" on the hero imagewidth and height<img> or an IntersectionObserverRelated: image compression, Core Web Vitals.
3 questions people ask next, answered from the sources on this page.
Not when done correctly. Google says it can crawl lazy-loaded content that loads whenever it is visible in the viewport, and recommends native lazy loading or IntersectionObserver. It can hide content when loading depends on user actions like scrolling or clicking.
No. Skip images likely to be visible when the page loads, especially the LCP image. web.dev warns that lazy loading these delays LCP. Lazy load images further down the page.
Lazy loading is the general idea of deferring non-critical resources. Code splitting is that idea applied to JavaScript: smaller chunks loaded on demand with dynamic import().
The free audit reads robots.txt, sitemaps, status codes, canonicals, redirects and structured data.