Languages
[Edit]
EN

React - async image loading

12 points
Created by:
Gigadude
791

In this short article, we would like to show how to load images in an async mode in React.

Quick solution (add loading="lazy" to img elements):

 

As async mode we understand the images loading occurs after all resources are loaded, do not blocking other sync resources loading. That approach speeds up page loading by splitting the loading process into 2 steps:

  • page loading (without async images) - we see all necessary things in the correct way faster,
  • async images loading - images are loaded when the page is ready.
Images async loading proof in Google Chrome DevTools - loaded after blue and red lines.
Images async loading proof in Google Chrome DevTools - loaded after blue and red lines.

Practical example

Edit

The main advantage of this solution is the web browser decides when image should be loaded to achieve the best performance.

Custom solution

Edit

In this section you can find solutuion that lets to load images in async mode, even the browser doesn't support loading="lazy".

References

Edit
  1. Improve your React application loading speed with async images 

Alternative titles

  1. React - image lazy loading
1
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.

ReactJS

React - async image loading
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join