Is Modernizr.load (Yepnope) meant to be used in the <head>

别说谁变了你拦得住时间么 提交于 2019-12-10 09:34:59

问题


Since Modernizr.load and Yepnope are asynchronous loaders, is it better performance-wise to use them in the <head> or at the end of the page?


回答1:


It depends on the resources being loaded. See this thread where Yepnope developer Alex Sexton says to combine all the resources into one call to the loader. In practice, if any of the resources you want to load with Modernizr.load or Yepnope affect what the user sees or needs when the page first loads, then IMO in most cases you want to call the loader after your critical resources but still in the <head>.




回答2:


Comment from yeapnope developer:

It's better at the end of the page, right before the closing </body>.

I think it is better to load them in the bottom page.

Modernizer and Yepnope need first be loaded in the page to load other scripts. So, when you add the <script src="modernizer.js"> you are blocking the rendering time in the browser. That happens because the browser stop all rendering while the script is downloading, compiling and executing.

As yahoo and google says defer loading scripts is always good.



来源:https://stackoverflow.com/questions/8042767/is-modernizr-load-yepnope-meant-to-be-used-in-the-head

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!