javascript - Preload external website content, then redirect - Stack Overflow

When leaving a website my user get a message you are now leaving, which redirects after 4 seconds. Can

When leaving a website my user get a message you are now leaving, which redirects after 4 seconds. Can that time be used to somehow preload the target site's content, so that after the redirect the site appears faster?

When leaving a website my user get a message you are now leaving, which redirects after 4 seconds. Can that time be used to somehow preload the target site's content, so that after the redirect the site appears faster?

Share Improve this question asked Mar 22, 2011 at 12:45 MoakMoak 12.9k27 gold badges117 silver badges168 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 6

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!)

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744132621a4559909.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信