October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk4 min

How to Make Website Thumbnails Load Lazily in a Directory Page

Use native loading="lazy" for offscreen directory thumbnails, keep likely above-the-fold images eager, and set dimensions to reserve layout space.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Put loading="lazy" on each thumbnail’s <img> when it starts outside the initial viewport. Keep images likely to appear immediately—including a hero or likely Largest Contentful Paint (LCP) image—eager, and reserve space with image dimensions so the directory does not jump as thumbnails load.

Use native lazy loading for offscreen thumbnails

For a directory rendered as ordinary HTML, add the attribute directly to the thumbnail image:

As an Amazon Associate I earn from qualifying purchases.

<a href="/listing/example">
  <img
    src="/images/example-thumbnail.jpg"
    alt="Example site preview"
    width="320"
    height="200"
    loading="lazy"
  >
</a>

The browser defers fetching an image marked lazy until it considers the image close enough to the viewport. The value is a browser hint, not a way to set an exact pixel threshold. Browser behavior and loading distance can vary. MDN explains lazy loading; its loading property reference documents the lazy and eager values and a dynamically created image-list example.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Keep visible and important images eager

Do not mark every image lazy indiscriminately. Images visible as the page first renders should generally load eagerly, especially a hero image or another likely LCP candidate. If shared code applies lazy loading to all images, explicitly leave initially visible thumbnails eager. The number of rows above the fold changes with viewport size, so check realistic mobile and desktop layouts rather than assuming a fixed row count. web.dev’s guidance on lazy loading covers the initial viewport and LCP considerations.

#1 Best Overall
Sale
HTML and CSS: Design and Build Websites
  • HTML CSS Design and Build Web Sites
  • Comes with secure packaging
  • It can be a gift option

Reserve the thumbnail’s space

Give each image a width and height, or otherwise reserve space using its aspect ratio. The browser can then lay out the directory before the image data arrives, reducing layout shifts. Without reserved space, a lazy image may have zero dimensions, which can also interfere with deciding when it approaches the viewport. See MDN’s <img> reference.

Apply the attribute in responsive and dynamically rendered directories

Responsive images with <picture>

When a <picture> element supplies responsive sources, put loading="lazy" on its child <img>, not on <picture>:

<picture>
  <source media="(min-width: 800px)" srcset="/images/example-large.webp">
  <img src="/images/example-small.webp" alt="Example site preview" width="320" height="200" loading="lazy">
</picture>

The selected source can change with the viewport, but the loading attribute belongs on the image element. See web.dev’s responsive images guide.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Images added by JavaScript

Set the property on each created image before adding it to the document. For example:

const img = document.createElement("img");
img.src = "/images/example-thumbnail.jpg";
img.alt = "Example site preview";
img.width = 320;
img.height = 200;
img.loading = "lazy";

const link = document.createElement("a");
link.href = "/listing/example";
link.append(img);
document.querySelector(".directory").append(link);

For images that should load immediately, use img.loading = "eager" or omit the lazy setting. MDN describes the loading property as widely available across browsers since March 2022; check your actual supported browser set if older browsers are in scope.

Choose native loading or custom visibility logic

For ordinary offscreen thumbnails, native loading="lazy" is the simple default and usually avoids needing a JavaScript library. Choose Intersection Observer when the interface needs custom behavior tied to an element entering or leaving an intersection—for example, a bespoke loading state or work beyond the browser’s built-in image deferral. Older scroll, resize, or orientation-change approaches require extra event-handling code; use them only when native loading and Intersection Observer do not meet the requirement.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshoot thumbnail loading

  • Images appear late even though they are visible: Check whether initially visible images were marked lazy. Make those images eager, and verify the layout at mobile and desktop viewport sizes.
  • Rows jump when thumbnails appear: Provide valid intrinsic width and height values or reserve the correct aspect-ratio space in CSS.
  • An image inside <picture> does not defer: Confirm loading="lazy" is on the child <img>, not the <picture>.
  • Code reports completion before all thumbnails are ready: Do not treat the window load event as proof that every lazy image has loaded. For a specific image, inspect its Boolean complete property; it indicates whether the image has finished loading or is ready to use.
  • Images load sooner or later than expected: That distance is controlled by the browser and may vary. The attribute does not provide a precise scheduling threshold; use Intersection Observer if custom intersection-driven behavior is necessary.

Or skip the browser setup

If your directory workflow needs screenshots of the pages rather than manually managed thumbnail assets, ScreenshotNeo provides a website screenshot API and MCP server. One GET request can return a PNG, JPEG, WebP, or PDF. Its capture can accept cookie and consent banners and remove 60+ known consent platforms, newsletter popups, and chat widgets before taking the shot; each step can be turned off.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Example cURL request, using the documented API at ScreenshotNeo’s documentation:

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits cost nothing; each response says which outcome occurred in the X-Page-Verdict and X-Billed headers. Its MCP server offers take_screenshot, get_page_info, and capture_pdf for Claude, Cursor, and other MCP clients. The Free plan includes 1,000 shots per month with no card; paid plans start at $5 for 3,000 shots.

Sign up for ScreenshotNeo’s free plan to get 1,000 screenshots a month without a card.

Quick Recap

SaleBestseller No. 1
HTML and CSS: Design and Build Websites
HTML and CSS: Design and Build Websites
HTML CSS Design and Build Web Sites; Comes with secure packaging; It can be a gift option
$14.94
SaleBestseller No. 2
SaleBestseller No. 4

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.