开发者

Does a element with display:none set in css still get downloaded by the browser?

开发者 https://www.devze.com 2023-01-08 06:50 出处:网络
Will the b开发者_开发问答rowser still download the image? <img src=\"/myimage.jpg\" style=\"display:none;\" />

Will the b开发者_开发问答rowser still download the image?

<img src="/myimage.jpg" style="display:none;" />


Yes, at least according to the Net console in Firebug.

As stated by thethimble, CSS is the presentation layer and affects rendering, not the actual processing of the page.

It wouldn't be outside the realm of possibility for some browsers, especially mobile, to potentially not download this in an attempt to optimize performance.


Yes. The rendering of the image has nothing to do with the downloading of the image.

Edit:
Try using Chrome or Firefox to perform a timing-test of a page's resources. Notice that all images get downloaded. Even ones whose display style is set to none.


Yes.

However, as a sidenote, some browsers won't download images with width and height attributes of 0. Can't find the source now, and just tested Firefox and Safari and they do download it. Must be IE, can anyone test for me? Thanks.

When in doubt, sniff the line, or use a browser specific tool (Firebug for Firefox, Web Inspector for Webkit, etc)


Quirks Mode: images and display: none

When image has display: none or is inside an element with display:none, the browser may opt not to download the image until the display is set to another value.

Only Opera downloads the image when you switch the display to block. All other browsers download it immediately.

0

精彩评论

暂无评论...
验证码 换一张
取 消