Last updated on February 8th, 2022 at 04:35 pm
Using this script we can preload an image in to the webpage and display it when needed. Once you click the Show Image button the image will display immediately with out any delay as it comes from the cache (preload). If your internet connection is slow then you can see the difference clearly. If you are in a fast net then try to connect to a heavy image to get the difference in speed.
If you take a closer look at the browser developer tools, under “Network” tab we can see the image is preloaded as shown below (before clicking the “Show Button”)