Search code examples
javascriptreactjsimageperformancebandwidth

Does React stores and knows the images?


I am a junior and this confuses me. I mean, if I use the same image more than once (on different routes) in React, does it mean that user downloads it more than once in browser?

I am just trying to learn that if using the same image will not cause more bandwidth in my website.


Solution

  • Yes, react stores images in cache memory. So it downloads the image only once and if you use the same image in other routes, it will not download it again. For example, you can look at the following video, the image is downloaded only once, and when the route is changed, the image is not downloaded again

    Test sample