What browsers download hidden images

前端 未结 2 1208
小蘑菇
小蘑菇 2020-12-16 13:46

相关标签:
2条回答
  • 2020-12-16 14:01

    Someone has tested this before:

    http://www.w3.org/2009/03/image-display-none/test.php

    Edit:
    Looks like the list does not contain many mobile browsers (yet).

    0 讨论(0)
  • 2020-12-16 14:09

    I would never call it an optimization for a browser to not download a hidden image. That might have dozens of good reasons and should (and will) still get downloaded by a browser. I don't have some table of numbers or browsers but I'm pretty much sure all mobile browsers will also download such an image as soon as the interpreter spots it.

    I'm afraid there is no silver bullet to conditionally load <img> tags with just html/css. Right now you'll need at least a little piece of ecmascript, but as always, I'm very sure the stackoverflow community will correct me if I'm wrong here.

    The <img> node has no property like .preventLoad (which would indeed be quite useful). Maybe it's time for a whatwg proposal, I'll join and support it :-)

    0 讨论(0)
提交回复
热议问题