How to Preload Images without Javascript?

后端 未结 9 1386
有刺的猬
有刺的猬 2020-12-01 02:48

In one of My Layout there are some large images (come from XML) which shown when I mouse hover on some some of the link, but when the Page loads and when i rollover It takes

9条回答
  •  猫巷女王i
    2020-12-01 03:24

    HTML5 has a new way to do this, by link prefetching.

    
    

    Just add many link tags as you need in your HTML and you are good to go. Of course, older browsers will not load the content this way.

    Note Above code will not work for Apple Safari safari does not support prefetch til now version 12 https://caniuse.com/#search=prefetch

    UPDATE

    If your server is served with HTTP2, you can also add a Link header in your response a made use of HTTP2 Server Push.

    Link: ; rel=preload; as=image;
    

提交回复
热议问题