简体   繁体   English

最好在哪里引用js库?

[英]html where is best to have references to js libraries?

I know that standard JS code, which will be immediately executed should be placed before body's closing tag. 我知道应该立即执行的标准JS代码应该放在body的结束标记之前。 But what about libraries? 但是图书馆呢? Where should I place eg reference to jQuery? 我应该在哪里放置例如对jQuery的引用?

Put Scripts at the Bottom so that they load after all DOM is loaded so less time to load page content. 将脚本放在底部,以便在加载所有DOM之后加载脚本,从而减少了加载页面内容的时间。

Put your jQuery code in DOM Ready 将您的jQuery代码放入DOM Ready中

Read Best Practices for Speeding Up Your Web Site 阅读加速网站的最佳做法

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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