Reputation:
Assuming I load the same image in different places inside the html file like:
<img src="image.png">
and after some code I load it again. That means it'll take html double effort to load the images? If yes is there any way to pre-load the image and then use it as many times as I want without re-loading it?
Thanks in advance for your answers...
Upvotes: 1
Views: 3054
Reputation: 7771
This will not preload the image, but you can add the image using JavaScript's appendChild()
method to put it wherever you want.
var image1 = new Image();
image1.src = 'http://placekitten.com/g/200/300';
document.body.appendChild(image1);
Upvotes: 1
Reputation: 1233
If they have the same real path, then browser will cache them.
Upvotes: 7