Does “display:none” prevent an image from loading?

前端 未结 17 1884
再見小時候
再見小時候 2020-11-22 05:13

Every responsive website development tutorial recommends using the display:none CSS property to hide content from loading on mobile browsers so the website load

17条回答
  •  醉话见心
    2020-11-22 05:30

    Yes it will render faster, slightly, only because it doesn't have to render the image and is one less element to sort on the screen.

    If you don't want it loaded, leave a DIV empty where you can load html into it later containing an tag.

    Try using firebug or wireshark as I've mentioned before and you'll see that the files DO get transferred even if display:none is present.

    Opera is the only browser which will not load the image if the display is set to none. Opera has now moved to webkit and will render all images even if their display is set to none.

    Here is a testing page that will prove it:

    http://www.quirksmode.org/css/displayimg.html

提交回复
热议问题