JavaScript tags, performance and W3C

。_饼干妹妹 提交于 2019-12-08 12:04:11

问题


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. Is this valid with W3C's recommendations? I learned that all JavaScript must be inside of head tag... Thank you.


回答1:


From the documentation:

This element may appear any number of times in the HEAD or BODY of an HTML document.




回答2:


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.




回答3:


Yes, the SCRIPT element is allowed as child of the BODY element:

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


来源:https://stackoverflow.com/questions/2812496/javascript-tags-performance-and-w3c

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