开发者

Fastest non-server side redirect method

I am trying to redirect users to a page, only from a specific page.

I have tried meta Refresh, windows.location, top.location.replace, but they all take a little too long to redirect as my client needs the page changed instantly or as close as possible. I am wondering if there is a faster, non-server method to do so. php header is also not an 开发者_Python百科option as the script has to be placed within a page.

Any ideas would be greatly appreciated!


Place both the meta and javascript method of your choice as close to the top as possible. Those are ALL the client-side redirect methods.

You can't get any faster without speeding up your server, or cutting down on page load time. If you can make the page load faster by removing content and/or images, external files, etc., you can improve the performance slightly.

If you really want to get into silly extremes, if you can pre-load the target page in a prior page in a hidden iframe, the transition will seem close to instant as the browser hits the local cache and skips the DNS lookup. Make sure your etags and cache control headers are set properly server side.

If you're concerned about the flicker where the client sees a real page load before getting redirected, consider setting the content to hidden with an inline style, or covering it with a white div, or something similar.


I'd argue that a meta-refresh would be the faster of those mentioned. Simply for the fact that it is top on the document and that JavaScript <script> tags are blocking while interpreted.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜