简体   繁体   English

延迟属性No Src里面什么也没有

[英]Defer Attribute No Src Nothing Inside

What happens when there is a script tag with a defer attribute, no src or async attribute, and nothing inside it, as in: script标签具有defer属性,没有srcasync属性,并且内部没有任何内容时,会发生什么情况,例如:

<script type="text/javascript" defer="defer"></script>

As far as I understand it, defer simply tells the page it can keep rendering while this script tag loads; 据我了解, defer只是告诉页面在加载此script标签时它可以保持渲染; the spec says it should be used when the tag has an src attribute, not when it has JavaScript inside it, but what about when it has nothing inside it AND no src attribute? 规范说应该在标记具有src属性时使用它,而不是在其中包含JavaScript的情况下使用,但是当标记中没有内容且没有src属性时该怎么办? Why would someone want that? 为什么有人要那个?

This is from my school. 这是我学校来的 It is on a Moodle page, version 1, not sure of minor version, so the page would be huge & change a lot based on who's logged in, etc.; 它位于Moodle页面的第1版上,不确定是次要版本,因此该页面很大,并且根据登录者等进行了很多更改。 please tell me what other source code you need to answer the question. 请告诉我您还需要其他哪些源代码来回答问题。

EDIT I wasn't very clear on what I'm asking. 编辑我不是很清楚我在问什么。 I know what happens in this situation, but I'm asking WHY someone would want it to happen this way. 我知道在这种情况下会发生什么,但是我想问为什么有人希望它以这种方式发生。 It seems useless to have a defer attribute with no JavaScript code to defer, so I'm wondering whether there are some side effects a website designer (circa 5-10 years ago) could use. 拥有没有JavaScript代码即可延迟的defer属性似乎没有用,所以我想知道网站设计师(大约5至10年前)是否可以使用某些副作用。

As Moodle is a big site, with many pages, it is possible that defer attribute is useful on some pages, but they put it on all the pages, even ones that don't need it. 由于Moodle是一个大型网站,包含许多页面,因此defer属性在某些页面上可能很有用,但他们会将其放在所有页面上,甚至不需要的页面也是如此。 Other than that, I can not think of a reason for it. 除此之外,我想不出原因。

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

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