Ask any question about Web Development here... and get an instant response.
Post this Question & Answer:
How can I implement lazy loading for images in a React app? Pending Review
Asked on Feb 22, 2026
Answer
Lazy loading images in a React app improves performance by deferring the loading of images until they are needed. This can be achieved using the `loading="lazy"` attribute in modern browsers or by using libraries like `react-lazyload` for more control.
<!-- BEGIN COPY / PASTE -->
import React from 'react';
import LazyLoad from 'react-lazyload';
const ImageComponent = () => (
<div>
<LazyLoad height={200} offset={100}>
<img src="path/to/image.jpg" alt="Description" />
</LazyLoad>
</div>
);
export default ImageComponent;
<!-- END COPY / PASTE -->Additional Comment:
- Use the `loading="lazy"` attribute directly on `
` tags for a native solution if browser support is sufficient.
- Consider using Intersection Observer API for custom lazy loading logic if you need more control.
- Ensure images have width and height attributes to prevent layout shifts.
- Test lazy loading performance impact using tools like Lighthouse.
Recommended Links:
