简体   繁体   中英

javascript - script from remote server slow load

In my site header I have a script tag which loads a secure certificate badge. This badge is loaded from the certificate authority server and is sometimes slow to load. This also slows down the loading of the rest of the site, since it is waiting for the badge to finish loading.

Is there any way to tell the rendering browser to continue loading other elements and not wait for the script to load?

您可以使用load.js之类的东西“延迟”加载脚本-防止脚本阻塞。

Put the script tag right before the

</body> 

tag. That way it will be loaded last and everything else can load first.

It's actually best practice to always put javascript in the footer instead the header for exactly this reason. For example, if you've ever implemented Google Analytics, they tell you to do this.

Here is a blog post about this from Yahoo! developers: http://developer.yahoo.com/performance/rules.html#js_bottom

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM