简体   繁体   English

JavaScript标签,性能和W3C

[英]JavaScript tags, performance and W3C

Today I was looking for website optimization content and I found an article talking about move JavaScript scripts to the bottom of the HTML page. 今天,我正在寻找网站优化内容,并且发现了一篇文章,内容涉及将JavaScript脚本移动到HTML页面的底部。 Is this valid with W3C's recommendations? 这对W3C的建议有效吗? I learned that all JavaScript must be inside of head tag... Thank you. 我了解到所有JavaScript都必须在head标签内...谢谢。

From the documentation : 文档中

This element may appear any number of times in the HEAD or BODY of an HTML document. 该元素可以在HTML文档的HEAD或BODY中出现任意次数。

It is valid. 是有效的。 Script tags can be in both the head and body. 脚本标签可以位于头部和正文中。 Moving the script tags to just prior to the closing body tag will significantly boost rendering time in IE, because scripts block parallel downloads. 将脚本标签移动到封闭主体标签之前将大大增加IE中的渲染时间,因为脚本会阻止并行下载。

是的, SCRIPT元素被允许作为BODY元素的元素

 <!ELEMENT BODY OO (%block;|SCRIPT)+ +(INS|DEL) -- document body --> 

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

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