Defering javascript - what is the correct html syntax defer or defer=“defer”

前端 未结 4 706
别跟我提以往
别跟我提以往 2020-12-21 03:10

What is the correct syntax for using the defer attribute in your javascript?

I have seen it done two ways:

1:



        
4条回答
  •  不思量自难忘°
    2020-12-21 03:35

    Since you reference HTML 4.01:

    This is a Boolean Attribute. Both forms are correct, but the specification recommends the former.


    If you were using XHTML then you would have to use the longer version.

    HTML 5 also allows both versions and removes the recommendation to use one over the other (since for compatibility with XHTML served as text/html, all modern browsers can handle both syntaxes).

提交回复
热议问题