开发者

Dynamically add image to web page head using Javascript - will browser fetch image?

开发者 https://www.devze.com 2023-02-28 01:07 出处:网络
If I were to dynamically add an image to a web page from JavaScript, and I add that image to the <head> section, then if I set the image src property, will the browser fe开发者_JS百科tch that im

If I were to dynamically add an image to a web page from JavaScript, and I add that image to the <head> section, then if I set the image src property, will the browser fe开发者_JS百科tch that image for me or will it not bother because as it doesn't display images from the <head> section in the rendered page, there is no point fetching it?

On IE8, it still fetched it, but I'm wondering if I can rely on that behavior on all browsers?


The only way you could know is through testing. It should be pretty easy to test with a large image, a collection of browsers, and a network bandwidth monitor.

Even if you can find that most major browser do this, I still wouldn't rely on it.

Why would you want to?

0

精彩评论

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