First thing you should understand is :
If your image has no semantic value use the property background-image
+ display:none
in a div
, this will prevent your image from being loaded.
Editing
Analyzing the situation I realized that the answer I added above is not true, ie at least in the case of Google Crome
this image is downloaded.
See for yourself:
div#image {
background-image: url("https://i.pinimg.com/736x/6b/b2/49/6bb249802cf0c124fde0ccbcea699340--funny-stuff-quotes.jpg");
width:500px;
height:500px;
display:none;
}
<div id='image'>
</div>
You can see it in the tab NetWork
, I also put an image to illustrate.
Why is it necessary for the image to load?
Due to the possibility of a Script
dynamically verify an element of the DOM
, the browser does not optimize elements or their contents.
Source: Does "display:None" Prevent an image from loading?
Working with media query you only upload what you need for the chosen resolution
– Otto
All right, man, what other method do you use for this? with
display: none
.. it is loaded in all media.– wDrik
instead of loading via html puts them in css and uses media query
– Otto
Got it, with the background. Thanks
– wDrik