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

For images below the initial viewport, add loading="lazy" to React’s regular <img> element. Keep the likely Largest Contentful Paint (LCP) image eager so the browser can discover and load it promptly. Add known dimensions to reserve layout space, then verify the result in the browser rather than assuming it improved performance.

Use the native loading hint for offscreen images

React passes the HTML image loading hint through its <img> component. Set loading="lazy" on an image that is not needed when the page first opens:

<img
  src="/images/article-detail.jpg"
  alt="Description of the image"
  width={1200}
  height={800}
  loading="eager"
/>

The browser can defer fetching the offscreen image until it approaches the viewport. This is a hint to the browser, not a precise fetch schedule that React controls. The dimensions let the browser reserve space before the image arrives. See React’s <img> reference.

Keep the likely LCP image eager

Do not apply lazy loading indiscriminately. An image visible immediately—particularly the likely LCP image—should generally remain eager. Delaying it can postpone its discovery and loading, undermining the page’s initial rendering. Leave the loading prop off that image unless measurements on the actual page support another choice. web.dev’s browser-level image lazy-loading guidance explains why initially visible images should not be deferred.

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

This distinction matters with server-rendered React too: React says an image is automatically preloaded by default, while loading="lazy" prevents that automatic preload. If an image should load immediately but at low priority, React documents fetchPriority="low" as a separate option; it is not a substitute for lazy loading an offscreen image. See React’s preload reference.

Add dimensions and responsive sources

When the image’s intrinsic dimensions are known, provide width and height. The browser can then reserve its space while it loads, reducing unexpected layout shifts. For responsive assets, use srcSet and sizes to let the browser select a suitable source; those attributes select the resource, while loading influences when it is requested. React documents these props in its image reference.

<img
  src="/images/guide-800.jpg"
  srcSet="/images/guide-400.jpg 400w, /images/guide-800.jpg 800w, /images/guide-1200.jpg 1200w"
  sizes="(max-width: 600px) 100vw, 800px"
  alt="A guide image"
  width={1200}
  height={800}
  loading="eager"
/>

Lazy loading changes request timing, not file weight. If images still transfer too many bytes, optimize dimensions, formats, and compression separately. MDN’s fast-loading HTML guidance treats image optimization as a distinct part of page performance.

Prefer native loading unless you need custom visibility behavior

For ordinary images lower on a page, start with the native attribute. Browser-level lazy loading avoids the extra JavaScript and implementation decisions of a custom loader. MDN describes the loading attribute as deferring offscreen resources until the user scrolls near them; MDN’s lazy-loading guide and web.dev cover the native approach.

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.

Use Intersection Observer when the experience needs custom behavior, such as a specific visibility threshold or a placeholder transition. It observes when an element enters or leaves the viewport, but a custom loader also means you must handle when to assign the image source, placeholders, failed loads, and support for your target browsers. MDN describes the API in its lazy-loading guide. The cited guidance does not establish a need for a third-party library for a typical React page.

Do not confuse image loading with React.lazy(). React’s lazy API defers loading a component’s code until the component is rendered; the HTML image loading="lazy" hint defers an image request. See React’s lazy reference.

Validate the change on your page

  1. Inspect the first viewport. Check representative mobile and desktop sizes and identify which image is visible immediately and likely to be the LCP image.
  2. Choose loading behavior by visibility. Keep the likely LCP image eager; set loading="lazy" on images below the initial viewport.
  3. Preserve layout and responsive selection. Add known width and height values and retain appropriate srcSet and sizes attributes.
  4. Inspect rendered markup and network activity. Confirm the visible image starts promptly and offscreen images are deferred as expected.
  5. Compare performance consistently. Use the same test conditions before and after. The effect depends on the actual page; do not claim a speedup without measuring it.

Common problems and fixes

  • The hero image appears late: it may have been marked lazy even though it is initially visible. Remove loading="lazy" from that image and verify its request starts promptly.
  • An image appears to load immediately despite the hint: native loading is browser-managed. Check the rendered <img>, its position at the tested viewport, and the network panel; the hint does not define an exact distance or timing.
  • The page jumps when an image arrives: provide its known width and height so space can be reserved in advance.
  • A responsive image downloads an unsuitable file: review the srcSet candidates and sizes value. These control source selection, not lazy-loading timing.
  • No image should render yet: avoid passing an empty string as src. React warns against it; omit the element or use null when there is no image to render.
  • A framework image component behaves differently: check its documentation and inspect the resulting HTML. Framework components may set lazy loading by default or expose an explicit preload option.
  • The page remains heavy after adding lazy loading: lazy loading defers requests but does not compress files. Optimize image dimensions, formats, and compression independently.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

If you need screenshots of pages to review how images behave, ScreenshotNeo can return a page screenshot or PDF. Here is a one-request example; see the API documentation for the available options.

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
  • Cookie and consent banners, newsletter popups, and chat widgets are removed before capture; each step can be turned off.
  • Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed. The response includes X-Page-Verdict and X-Billed headers.
  • An MCP server provides take_screenshot, get_page_info, and capture_pdf tools for AI agents and MCP clients.
  • The Free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 screenshots. Yearly billing gives two months free, and every feature is available on every plan.

Sign up for ScreenshotNeo’s free plan: 1,000 screenshots a month, no card required.

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.

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.