Web pages use HTML elements to embed images, like all HTML elements, elements can be manipulated by scripts (setting the SRC attribute of an element, pointing it to a new URL causes the browser to load and display a new picture). In order for the picture to be cached, the client JS defines an API that first uses the image () constructor to create an offscreen picture object, and then sets the desired URL for the SRC attribute of the object, which is not visible because the picture element is not added to the document. However, the browser will still load the picture and cache it.
// picture paths that need to be preloaded are stored in the array var imgsrc=[ "Images/34.jpg", "Images/32.jpg", "Images/33.jpg" ]; // initializing an Image object var New Image (); // iterates through the path of an array, preloaded to the client for (var i = 0; i < imgsrc.length; i++) { = imgsrc[i];}