Ask any question about Web Development here... and get an instant response.
Post this Question & Answer:
How can I implement lazy loading for images to improve page performance?
Asked on Mar 06, 2026
Answer
Lazy loading is a technique used to defer the loading of images until they are needed, improving page performance by reducing initial load time and bandwidth usage. This can be achieved using the `loading="lazy"` attribute in HTML or by implementing a JavaScript-based intersection observer.
<!-- BEGIN COPY / PASTE -->
<img src="image.jpg" alt="Description" loading="lazy">
<!-- END COPY / PASTE -->Additional Comment:
- The `loading="lazy"` attribute is natively supported in most modern browsers.
- For older browsers, consider using a JavaScript library like `lazysizes` for polyfill support.
- Lazy loading helps improve performance, especially on pages with many images.
- Ensure that images have descriptive alt text for accessibility.
Recommended Links:
