开发者

Preload external website content, then redirect

When leaving a website my user get a message you are now leaving, which redirects after 4 seconds. Can that time be used to someho开发者_如何学运维w preload the target site's content, so that after the redirect the site appears faster?


If the site to be fetched is on your domain, you can parse the next file with JavaScript and request the assets.

If not, you can't figure out its assets (not via XHR anyway, most of the time) so you can't preload them. You could hack it by placing the site in a hidden iframe. You could also use your server as a proxy, to get a list of assets and pass it to your HTML to start preloading them.

You could try also using this meta tag...

<link rel="prefetch" href="/images/big.jpeg">

Source.

It is a lot of effort for arguably not much gain though.


You could start loading the site into an invisible <iframe>. If it's cached properly, this will reduce load time when the user actually enters the page.

This would however have all kinds of potential side effects, like autoplay music and videos starting in the background.

I would tend to leave this kind of preloading to the web browser (and/or the prefetch tag that @alex shows!)

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜