How to Test Image Loading When Lazy Loading Is Used
Verify that lazy images wait until needed, load before they appear, preserve layout, and remain discoverable—without delaying your LCP image.

To test lazy image loading, record image requests during a clean page load, then scroll through the page under a throttled network and confirm each image is fetched, decoded, and painted as it approaches the viewport. Also check layout stability, failures, responsive sources, and the rendered DOM. Do not use window.load alone as a pass condition: a lazy image near the viewport can still be pending when that event fires.
The goal is not to prove that every browser waits until one exact scroll distance. Browsers choose loading thresholds using heuristics that can vary by resource type and connection. Test the behavior you need: below-the-fold images should generally be deferred, while images should arrive in time to display smoothly. Keep above-the-fold and likely Largest Contentful Paint (LCP) images out of lazy loading.
1. Build a page that exposes the cases you care about
A useful test page has enough variety to reveal mistakes. Include several images well below the fold, one near the fold, and a visible hero image that represents your likely LCP candidate. If your application uses them, include responsive srcset and <picture> sources, dynamically inserted images, and images inside a carousel, modal, or nested scrolling container.
Reserve space for each image using intrinsic dimensions or an equivalent aspect ratio. That lets you see whether loading causes layout shifts instead of confusing a moving page with a loading delay. Give meaningful images useful alternative text; decorative images should have an intentional empty alt value.
<main>
<section class="hero">
<img
src="/images/hero-large.webp"
width="1600"
height="900"
alt="A person using the product"
fetchpriority="high"
>
</section>
<section class="gallery">
<img src="/images/item-1.webp" width="800" height="600"
loading="lazy" alt="Red ceramic bowl">
<picture>
<source media="(min-width: 900px)" srcset="/images/item-2-wide.webp">
<img src="/images/item-2.webp" width="800" height="600"
loading="lazy" alt="Blue glass vase">
</picture>
</section>
</main>
This sample leaves the hero eager and marks below-content images for native lazy loading. Adapt dimensions, alt text, and paths to your page. The loading attribute expresses intent; the browser controls the actual fetch threshold.
2. Capture a clean initial load in DevTools
- Open Chrome DevTools before navigating to or reloading the test page.
- In Network, enable Disable cache while DevTools is open. Use a hard reload so memory or disk cache does not hide requests.
- Filter the request list to images. Record each relevant request’s URL, start time, status, transferred size, and initiator. Save a HAR if you need to compare runs.
- Before scrolling, check which requests started. The hero and currently visible images should load as needed. Images far below the fold should generally not all be fetched immediately.
Interpret the result as a behavior check, not a pixel-distance test. Chrome and other browsers may fetch an image before it enters the visible area, and their lead distance can vary with effective connection and resource type. Google’s web.dev guidance describes these thresholds as browser heuristics that can change over time. See browser-level image lazy loading.

3. Throttle the network and scroll in small steps
Choose a representative constrained profile, such as Fast 3G or Slow 3G, in DevTools Network throttling. Scroll a little at a time toward each image. For each one, look for a request that starts before or as it becomes visible, a successful response, and the actual image paint. A request appearing in Network does not by itself prove that the user saw the image promptly.
Repeat at the viewport sizes and connection conditions that matter to your users. If images arrive late, experiment with the implementation’s trigger distance or browser-supported strategy under throttling. Do not turn one observed distance into a universal assertion: the browser may adjust its threshold. The web.dev article reports that in its cited Chrome for Android measurements, 97.5% of below-the-fold images on 4G and 92.6% on slow 2G were fully loaded within 10 milliseconds of becoming visible. Those historical figures are context, not a guarantee for your page or current browser.
4. Inspect markup and image state
In Elements, inspect the actual rendered image. Confirm the intended img has loading="lazy", including the fallback img nested inside picture. Check that src and srcset are populated as intended and that CSS does not keep the image hidden or give it zero dimensions. The selected request may differ by viewport because of responsive sources, so check the current source rather than assuming the fallback URL is always requested.
Do not mark the run failed just because window.load fired before every lazy image finished. MDN documents that lazy-loaded images in the visual viewport may still be pending at that point. Instead, observe each target through the scroll sequence and verify its request, response, and rendered result. See MDN’s img loading reference.
5. Measure LCP and layout stability
Record a Performance trace and run Lighthouse at representative viewport and network settings. Compare the lazy-loading version with an appropriate eager-loading baseline. Focus on LCP, the image request start time, transferred bytes, and whether scrolling feels smooth. A first-viewport hero or other likely LCP image should not be delayed behind lazy-loading behavior; Google’s guidance warns that lazy-loading an above-the-fold image can delay the critical resource. See web.dev’s lazy-loading guidance and Google’s image SEO guidance.

Watch the page while images load and decode. Reserved dimensions should keep the surrounding content in place. If the page jumps, inspect missing or incorrect width and height attributes, aspect-ratio rules, and late changes to the image container. Lazy media without placeholders can create layout shifts and additional layout work.
6. Test edge cases deliberately
A passing happy path is not enough if the application changes image sources or visibility dynamically. Exercise these cases and record what the user sees:
- Broken URL: the request should fail visibly and the page should provide a sensible fallback. Check that the alt text remains available.
- Slow response and offline transition: confirm loading state, eventual recovery where applicable, and a clear failure state when recovery is impossible.
- Cached response: test both with cache disabled for request timing and with cache enabled for repeat visits. A cache hit may not look like a normal network transfer.
- Rapid scrolling: move past several images quickly and check that they do not remain blank after the user stops.
- Back/forward navigation: navigate away and return. Verify images restored from browser history or cache still render correctly.
- Hidden slides, modals, and tabs: test the moment an image becomes visible, especially if CSS visibility or component mounting controls its source.
- Dynamic insertion: append an image after initial load and verify that it receives a source and the intended loading behavior.
- Supported browser range: test each browser your product supports. For script-based loading, exercise the fallback path where IntersectionObserver is unavailable.
7. Test IntersectionObserver implementations
Native loading="lazy" is the simplest option for ordinary img and picture content and does not require JavaScript. An IntersectionObserver implementation can offer control over a trigger margin or support custom components and CSS background images, but it adds observer, fallback, and dynamic-content paths to test.
For an observer, check the root (viewport or intended scroll container), rootMargin, threshold, callback, and assignment of src or srcset. Confirm the observer stops watching an image after it has been activated, and that teardown disconnects it when the component is removed. IntersectionObserver reports intersection changes asynchronously; it avoids repeatedly measuring every target in a scroll handler. Read the MDN Intersection Observer API guide.
const observer = new IntersectionObserver((entries, currentObserver) => {
for (const entry of entries) {
if (!entry.isIntersecting) continue;
const img = entry.target;
if (img.dataset.src) img.src = img.dataset.src;
if (img.dataset.srcset) img.srcset = img.dataset.srcset;
currentObserver.unobserve(img);
}
}, {
root: null,
rootMargin: '300px 0px',
threshold: 0
});
document.querySelectorAll('img[data-src], img[data-srcset]')
.forEach(img => observer.observe(img));
This illustrative implementation assumes JavaScript runs and that your markup uses data attributes. Production code should also define a no-IntersectionObserver fallback, account for images inserted later, preserve responsive source behavior, and expose a useful failure state. Test a nested scroll container by setting root to that container and checking that entry and exit callbacks match its viewport.
8. Check crawler visibility in the rendered page
Inspect the rendered DOM, not just the original HTML response. Google Search Central says that if image or video URLs appear in the rendered src attribute of the relevant element, the setup works correctly for discovery. Content should load when it becomes visible and must not require a user click or scroll for Google to discover it. See Google’s lazy-loading guidance.
For script-based solutions, ensure the crawler can render the page and that your code eventually places the real URL in src or the appropriate responsive source attributes. A URL held only in an application-specific data attribute may not be discoverable as an image source in the rendered markup.
9. Use these pass/fail criteria
- Deferred: non-visible images are not all eagerly fetched at initial load, subject to browser heuristics.
- Timely: each image request begins early enough to decode and paint as it approaches visibility under constrained conditions.
- Complete: intended images eventually succeed, and failures have a visible, accessible fallback.
- Stable: reserved dimensions prevent meaningful layout shifts during loading and decode.
- Critical-path safe: above-the-fold and LCP candidates are not held back by lazy loading.
- Discoverable: rendered markup exposes image URLs and does not depend on crawler interaction.
- Portable: tests cover supported browsers, viewport sizes, scroll containers, dynamic content, and fallback paths.
Native lazy loading or IntersectionObserver?
| Consideration | Native loading="lazy" |
IntersectionObserver |
|---|---|---|
| Ordinary images | Direct fit for img and picture. |
Works, with application code to maintain. |
| Trigger control | Browser chooses the threshold. | You can tune root, margin, and threshold. |
| Backgrounds or custom components | Does not directly provide general component logic. | Can activate custom loading behavior. |
| JavaScript and fallback | Can work without your JavaScript loader. | Needs observer support handling and a fallback. |
| SEO and rendered DOM | Keep real URLs in normal image source attributes. | Ensure scripts populate rendered source attributes without user interaction. |
| Operational complexity | Fewer moving parts. | Test dynamic content, nested roots, cleanup, and errors. |
Performance, reliability, and cost notes
Lazy loading can reduce initial image work when a page contains substantial below-the-fold media, but its value depends on actual user behavior and the page’s resources. The web.dev research cited above reported that sites at the 90th percentile sent over 5 MB of images on desktop and mobile in 2019; that figure motivates measuring your own page rather than predicting savings from a generic number. Record transferred bytes and request timing in your own representative runs.
For reliability, test both cold and warm cache behavior, slow networks, and failed requests. Keep placeholders stable, avoid making critical hero content depend on a delayed observer callback, and ensure dynamic UI updates preserve the image’s source and dimensions. Repeat measurements across relevant browsers because thresholds and scheduling can differ.
Testing with Chrome DevTools and Lighthouse has no separate service cost. For a repeatable workflow, save traces or HAR files with the tested viewport, throttle profile, cache state, and build revision. That context makes future comparisons useful and prevents a cached or differently throttled run from being mistaken for a code improvement.
Or skip the browser setup
ScreenshotNeo is a website screenshot API and MCP server. Its screenshot capture supports full-page images and loads lazy images, so you can capture the rendered result without setting up a browser script. For diagnosing behavior, keep the DevTools procedure above: a final screenshot shows what rendered, while the Network panel shows when requests started.
One GET request returns an image or PDF. The API accepts familiar screenshot parameter names, which can make switching straightforward. See the ScreenshotNeo API documentation.
curl -G "https://api.screenshotneo.com/v1/shot" \
-d access_key=YOUR_API_KEY \
--data-urlencode url=https://stripe.com \
-o shot.webp
import requests
r = requests.get(
"https://api.screenshotneo.com/v1/shot",
params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"},
timeout=90,
)
open("shot.webp", "wb").write(r.content)
const q = new URLSearchParams({
access_key: 'YOUR_API_KEY',
url: 'https://stripe.com'
});
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
if (!res.ok) throw new Error(`Screenshot request failed: ${res.status}`);
await Bun.write('shot.webp', res);
Replace the example URL with your page. The Node.js snippet uses Bun to write the response body to a file; in Node, write the response bytes with your preferred filesystem method. ScreenshotNeo removes cookie banners, popups, and chat widgets before the shot. Bot checks, blank pages, and failed loads are never billed; an MCP server lets AI agents take screenshots. The free plan includes 1,000 screenshots per month with no card, and paid plans start at $5 for 3,000. Sign up for 1,000 free screenshots a month, with no card.
Troubleshooting
| Symptom | Likely cause | What to check or fix |
|---|---|---|
| Every image is requested immediately | Images are not marked lazy, are close enough for browser heuristics, or script code assigned all sources at startup. | Inspect attributes and initiators. Test images farther below the fold; avoid asserting a fixed threshold. |
| Image appears late after scrolling | Custom observer margin is too small, source assignment is delayed, or a constrained response is slow. | Check the request start and callback timing under throttling; adjust the observer margin and retest. |
load fires but an image is blank |
A lazy image can still be pending when the window load event fires. | Track the individual request and paint through scrolling; use per-image load/error handling if needed. |
| Page jumps as image appears | Dimensions or aspect ratio were not reserved, or CSS changes the container size. | Set correct width and height or a stable aspect ratio; inspect layout shifts in a Performance trace. |
| Wrong responsive image appears | srcset, sizes, or picture media conditions select another source. |
Inspect the current source at each viewport and verify all candidates exist and have matching dimensions. |
| Nested gallery never triggers | Observer root points at the top-level viewport instead of the scroll container. | Set the intended container as root and test scrolling within it. |
| Images added later stay blank | New nodes were never observed or receive no source assignment. | Observe nodes when inserted, or use native lazy loading on the inserted img. |
| Search rendering misses images | Real URLs are only in data attributes or loading requires a click/scroll interaction. | Inspect rendered HTML and ensure source URLs appear in image source attributes without user action. |
FAQ
Should I lazy-load every image?
No. Keep important first-viewport images, especially the likely LCP image, on the critical path. Apply lazy loading to content that starts outside the viewport and verify the result at your target sizes.
Can I test this from a screenshot alone?
A screenshot can confirm the final visible state. It cannot show request timing, cache behavior, or whether images were fetched too early. Use Network and Performance tools for those questions.
Does a browser fetch an image exactly when it enters the viewport?
Not necessarily. Browsers may start earlier to leave time for loading, and the threshold is heuristic. Judge whether it is deferred initially and ready when users reach it.
Do lazy images need alt text?
Lazy loading does not change accessibility requirements. Meaningful images need a useful text alternative; decorative images should be marked as decorative with an empty alt value.


