[英]HTML JavaScript Script Tag
Why are javascript <script>
tags placed in the <body>
rather than the other script
tags which are usually placed in the <head>
?为什么 javascript <script>
标签放在<body>
中,而不是通常放在<head>
中的其他script
标签?
<script>
element after the elements it needs to access is one way to achieve this.将<script>
元素放在它需要访问的元素之后是实现此目的的一种方法。 The introduction of the defer
attribute allows both these benefits to be gained while leaving the <script>
element in the <head>
which also allows the HTTP request for the JS to run in parallel. defer
属性的引入允许获得这两个好处,同时将<script>
元素留在<head>
中,这也允许 HTTP 请求 JS 并行运行。 Not everybody has caught up with this development.并不是每个人都赶上了这一发展。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.