Clarification on `async` and `defer` together

Stu Cox <[email protected]> Sun, 7 Jul 2013 14:59:36 +0100
Newsgroups gmane.comp.web.html.general
Message-ID <CAJ-2Ov4Zt7MioELFtOMVb3KP2t9_CMcUHcOmkbZst525dZ7Brw@mail.gmail.com>
--001a11c3a968625fef04e0ec5833
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: quoted-printable

Not entirely sure if this is the right reference doc:
http://www.w3.org/TR/html-markup/script.html =96 but it doesn't make it cle=
ar
what should happen if both `async` and `defer` attributes are set on a
`<script>` element:

<script src=3D"myscript.js" async defer>

Browsers all seem to give `async` precedence, and I agree that this is the
most desirable behaviour, however logically `async` and `defer` aren't
necessarily mutually exclusive. If both were applied, it might be
reasonable to assume the behaviour might match that of `defer` alone.

Could a note be added to this / any other relevant docs highlighting this
behaviour?

The WHATWG spec [1] suggests this behaviour, but isn't incredibly clear
about it either.


[1]
http://www.whatwg.org/specs/web-apps/current-work/multipage/scripting-1.htm=
l

--001a11c3a968625fef04e0ec5833
Content-Type: text/html; charset=windows-1252
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div style>Not entirely sure if this is the right referenc=
e doc: <a href=3D"http://www.w3.org/TR/html-markup/script.html">http://www.=
w3.org/TR/html-markup/script.html</a> =96 but it doesn&#39;t make it clear =
what should happen if both `async` and `defer` attributes are set on a `&lt=
;script&gt;` element:</div>

<div style><br></div><div style>&lt;script src=3D&quot;myscript.js&quot; as=
ync defer&gt;</div><div style><br></div><div style>Browsers all seem to giv=
e `async` precedence, and I agree that this is the most desirable behaviour=
, however logically `async` and `defer` aren&#39;t necessarily mutually exc=
lusive. If both were applied, it might be reasonable to assume the behaviou=
r might match that of `defer` alone.</div>

<div style><br></div><div style>Could a note be added to this / any other r=
elevant docs highlighting this behaviour?</div><div style><br></div><div st=
yle>The WHATWG spec [1] suggests this behaviour, but isn&#39;t incredibly c=
lear about it either.</div>

<div style><br></div><div style><br></div><div style>[1] <a href=3D"http://=
www.whatwg.org/specs/web-apps/current-work/multipage/scripting-1.html">http=
://www.whatwg.org/specs/web-apps/current-work/multipage/scripting-1.html</a=
><br>

</div><div style><br></div></div>

--001a11c3a968625fef04e0ec5833--