CSS - Media Queries loading backgrounds. How do they behave?

1

I'm making a site responsive and would like to load different images in the background depending on the device. I will respect the use of mobile user data and do not want to force the loading of a 1920x500 image for example.

If I use media queries in CSS (as represented below) what exactly happens?

A) Both images are loaded but only one is shown;

B) Only the image that is in the condition of the user's screen is loaded;

C) [other answer?]

@media screen and (min-width: 768px) {
    #divFundo {
        background-image: url("../images/imagem_grande.png");
    }
}
@media screen and (max-width: 768px) {
    #divFundo {
        background-image: url("../images/imagem_pequena.png");
    }
}
    
asked by anonymous 15.09.2017 / 16:47

1 answer

0
Look, I'm going to do better than answer you directly. Try opening this page in google Chrome with the console open. Go to the network tab, select "IMG".

This screen will show you in order everything that is being downloaded to the client machine. In it you will see if the images were uploaded or not.

Tip: Do this again, but press CTRL + F5 to force the browser to download everything again.

    
15.09.2017 / 16:54