2

This question follows up on this 4 years old answer. The author suggested afterwards that browsers are gradually changing their behaviour about hidden images. My question is: how is it today? Do current browsers load such images or not?

Community
  • 1
  • 1
drake035
  • 2,935
  • 25
  • 85
  • 161

2 Answers2

3

Yes. Images are still loaded. The reason for that is, if one doesn't want the image to be there, they wouldn't have the element installed in the first place. So it's rightly assumed that the image will be displayed at some point, so it's loaded.

It's also a separation of concerns. Content should not be influenced by styling. CSS should not be the determinator for HTML content. display:none; only states that the image should not be shown and has nothing to do with the content itself.

Rob
  • 13,342
  • 26
  • 40
  • 60
2

Browsers only hide the image when it receives CSS rule. So image and CSS rules both loaded first, then its displays become none. So the image loads even their display is none in CSS. An element loaded or not is directly depends upon the server, not the browser. It just hides the content that has loaded. So in either case none or block the contents loads. And content loaded from the server is beyond the control of browsers.

Siraj Alam
  • 5,569
  • 5
  • 39
  • 55