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

For ordinary images below the fold, use the browser’s built-in loading="lazy" attribute. Use JavaScript with IntersectionObserver only when you need a custom loading threshold, have a nonstandard target, or need a fallback. Keep images likely to appear in the first viewport—especially the Largest Contentful Paint (LCP) image—eager, because deferring them can delay the page’s most important visual content.

Choose native lazy loading or JavaScript

Native lazy loading is the least complex choice for ordinary offscreen <img> elements. It needs no separate library, works when JavaScript is disabled, and lets the browser decide how far ahead of the viewport to fetch images. Use JavaScript when that browser-controlled threshold is not suitable, when content is not represented by a regular image element, or when your supported browser population needs a fallback.

Approach Best for Control Tradeoff
Native loading="lazy" Ordinary offscreen images, including an image inside a <picture> The browser chooses when to fetch Minimal code; threshold is not configurable
JavaScript with IntersectionObserver Custom preload distance, nonstandard targets, or fallback behavior Set the observed root and rootMargin More code and failure cases to handle
Scroll and resize handlers Compatibility fallback where needed Fully custom More event-handling and geometry work

Browsers that do not recognize loading ignore the attribute and load images normally, without deferring them. Feature detection with 'loading' in HTMLImageElement.prototype is available if you have a demonstrated need for a fallback; do not add a library by habit. See web.dev’s browser-level image lazy-loading guidance.

Keep initially visible and LCP images eager

Do not lazy-load an image likely to appear in the initial viewport, particularly the LCP candidate. With lazy loading, the browser waits for layout information before deciding whether to fetch the image. If that image is visible immediately, this can add avoidable resource delay. Keep its URL discoverable in the initial HTML. Normal image loading is eager by default; adding loading="eager" is generally unnecessary unless tooling requires an explicit value. The web.dev Optimize LCP guidance says not to lazy-load the LCP image. If appropriate, fetchpriority="high" can hint that a likely LCP image is important, but use the hint selectively and check the actual resource priority.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter
  • Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
  • Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
  • Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
  • Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
  • 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.

Use native lazy loading for ordinary offscreen images

Add loading="lazy" to images below the fold, while keeping real source URLs in the markup. Include intrinsic dimensions so the browser can reserve the image’s space before the file arrives.

<img src="gallery-01.webp" loading="eager" width="800" height="600" alt="Description">

For responsive <picture> markup, place the loading attribute on its fallback <img>. Native thresholds are browser decisions; this attribute does not let you specify a distance from the viewport.

Rank #2
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter
  • 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
  • 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
  • Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
  • 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
  • What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.

Implement a custom threshold with IntersectionObserver

Use IntersectionObserver when you need to start loading at a chosen distance before an image enters view. A positive bottom rootMargin expands the observer’s effective area below the viewport. The right distance depends on image placement, viewport, network conditions, and how quickly the asset can load; 0px 0px 256px 0px is an illustrative value, not a universal setting.

This example stores the real URL in data-src, assigns it when the image approaches the viewport, and then stops observing it. It uses native loading when available and falls back to eager source assignment otherwise. Apply it only to deferrable images; leave initial-viewport and LCP images in ordinary HTML with their real src.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter
  • Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
  • Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
  • Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
  • Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
  • What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
<img class="js-lazy" data-itgw-was-lazy-src="gallery-01.webp" width="800" height="600" alt="Description">

<script>
  const images = document.querySelectorAll('img.js-lazy[data-src]');

  if ('loading' in HTMLImageElement.prototype) {
    images.forEach((img) => {
      img.src = img.dataset.src;
      img.loading = 'lazy';
      img.removeAttribute('data-src');
    });
  } else if ('IntersectionObserver' in window) {
    const observer = new IntersectionObserver((entries, observer) => {
      entries.forEach((entry) => {
        if (!entry.isIntersecting) return;
        const img = entry.target;
        img.src = img.dataset.src;
        img.removeAttribute('data-src');
        observer.unobserve(img);
      });
    }, { rootMargin: '0px 0px 256px 0px' });

    images.forEach((img) => observer.observe(img));
  } else {
    images.forEach((img) => {
      img.src = img.dataset.src;
      img.removeAttribute('data-src');
    });
  }
</script>

The native branch above still uses JavaScript to assign the URL from data-src. That pattern is appropriate only when the project intentionally manages sources in JavaScript. For regular images, prefer a real src in the HTML with loading="lazy", which remains available when scripts are disabled and is easier for crawlers to inspect.

Fallback behavior and accessibility

Do not leave meaningful images behind an empty placeholder if JavaScript is unavailable. For content that must be accessible without scripts, keep the image URL in ordinary markup and use the native attribute, or provide a deliberate non-JavaScript fallback for the JavaScript-dependent design. Supply useful alt text for informative images and an empty alt="" for purely decorative images.

Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray
  • Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
  • Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
  • Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
  • Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
  • Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft

MDN lists an IntersectionObserver polyfill or scroll, resize, and orientation-change handlers as compatibility alternatives. Prefer the observer where available rather than repeatedly measuring every image’s position during scroll events. See MDN’s lazy-loading guide and web.dev’s lazy-loading best practices.

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

Reserve layout space to prevent shifts

Set image width and height, or reserve an equivalent aspect ratio in CSS, so the layout has the correct space before the image loads. Without dimensions, an image may initially occupy zero space. In a gallery, that can lead the browser to decide that many or all images are in view and fetch them early; when images appear, they can also push other content around. A dimensionally consistent placeholder can reserve space where that fits the design.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display
  • 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
  • Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
  • Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
  • HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
  • What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.

Test the performance effect

Lazy loading is useful when it reduces early work for noncritical images, but it is not automatically faster for every page or image. Browser heuristics, viewport size, network conditions, and image position all affect the result.

  1. Check representative viewports. Test mobile and desktop sizes because the first viewport contains different content at each size.
  2. Inspect the network waterfall. Confirm that below-the-fold assets are deferred as intended, visible images appear promptly, and the likely LCP image is not delayed. Check its resource priority if you use fetchpriority.
  3. Compare performance evidence. Assess lab results and field performance where available; a single viewport or run does not establish a universal improvement.
  4. Inspect rendered markup and discoverability. Google recommends that lazy-loaded content load when it becomes visible without requiring user interaction. Use Google Search Central’s lazy-loading guidance and URL Inspection Tool to check rendered HTML; verify relevant image URLs appear in src attributes.

For large images inserted by JavaScript, decoding may also require main-thread work. HTMLImageElement.decode() is a possible technique, but it has support and complexity tradeoffs and is not a requirement for ordinary small images.

Troubleshoot common lazy-loading problems

  • The hero image appears late or LCP worsens: Remove lazy loading from the initially visible or LCP image, keep its URL in initial HTML, and inspect its network priority. Consider fetchpriority="high" only when appropriate.
  • Images load immediately instead of being deferred: Check that target images have dimensions or a stable aspect ratio, and verify they are actually below the fold at the tested viewport. Zero-sized images can affect visibility decisions.
  • Images never appear: In a JavaScript implementation, inspect console errors and confirm the observer runs, the element is observed, and its real URL is assigned to src when it intersects. Make sure no content depends on an interaction to trigger loading.
  • Content jumps when an image arrives: Add intrinsic dimensions or reserve a matching aspect ratio in the layout.
  • Search rendering misses images: Check the rendered HTML for the image URL in src, and confirm the image loads when visible without a click, scroll-triggered interaction, or other user action.
  • Older browsers do not defer native images: They may ignore loading="lazy" and load normally. Add a JavaScript fallback only if support requirements justify the extra code.

Or skip the browser setup:

ScreenshotNeo is a website screenshot API and MCP server. Make a single request for a page screenshot; see the API documentation for options and setup.

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

Cookie banners are accepted and removed before capture, along with supported newsletter popups and chat widgets. Bot checks, blank pages, failed loads, timeouts, and cache hits are not billed. An MCP server lets AI agents use screenshot tools, and the free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000. Sign up for free.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

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

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.