When a page loads an image, does it only load it once, or every time it is in layout?

When a page loads an image, does it only load it once, or every time it is in layout? and what about jquery, does img add its reboot again? I ask about this because I have a high resolution image, but you need to use it in many cases in markup.

<img src="hello.jpg" />
<img src="hello.jpg" />
<img src="hello.jpg" />


var myimg = $('<img src="hello.jpg />');
$('img').append(myimg);
+3
source share
3 answers

The browser will download the same image only once per page load, unless you use aggressive anti-caching headers (I see no reason why you are loading the page).

, net Firebug. net.

for (var i = 0; i < 10; i++) {
   var myimg = $('<img src="hello.jpg alt="" />');
   $('img').append(myimg);
}
+5

, ... , ...

+1

Source: https://habr.com/ru/post/1756667/


All Articles