Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
由于Modernizr.load和Yepnope<head>是异步加载器,因此在页面末尾或末尾使用它们在性能方面是否更好?
<head>
这取决于正在加载的资源。请参阅此线程,其中Yepnope开发人员 Alex Sexton 说将所有资源组合到对加载程序的一次调用中。在实践中,如果您想要加载的任何资源Modernizr.load或Yepnope影响用户在页面首次加载时看到或需要的内容,那么 IMO 在大多数情况下您希望在关键资源之后调用加载程序,但仍位于<head>.
Modernizr.load
Yepnope
yeapnope开发者的评论:
最好在页面末尾,就在关闭之前</body>。
</body>
我认为最好将它们加载到底部页面中。
Modernizer 和 Yepnope 需要先在页面中加载才能加载其他脚本。因此,当您添加时,<script src="modernizer.js">您会阻止浏览器中的渲染时间。发生这种情况是因为浏览器在脚本下载、编译和执行时停止了所有渲染。
<script src="modernizer.js">
正如雅虎和谷歌所说,延迟加载脚本总是好的。