You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Another question is whether defer can be used for in place scripts like the following:
<script>anchors.add();</script>
I.e. is the following valid?:
<script defer>anchors.add();</script>
The answer is no, defercan't be use on such inline scripts. The following quotation is taken from the MDN web docs page for the <script> element when the defer attribute is described:
⚠️ Warning: This attribute must not be used if the src attribute is absent (i.e. for inline scripts), in this case it would have no effect.
The defer attribute has no effect on module scripts — they defer by default.
Activity
[-]Revise `<script>` elements to user `defer` loading[/-][+]Revise `<script>` elements to use `defer` loading[/+]delphidabbler commentedon Oct 14, 2022
Need to check how the use of
deferloading affects code that calls into deferred scripts.For e.g., the following code is included towards the end of the body of
default.html:If
is moved to the head section and set to defer loading, will the
line still work if left at the bottom of the body, or will it need moving into a script that triggers when the document has loaded?
delphidabbler commentedon Oct 14, 2022
Another question is whether
defercan be used for in place scripts like the following:I.e. is the following valid?:
delphidabbler commentedon Oct 14, 2022
The answer is no,
defercan't be use on such inline scripts. The following quotation is taken from the MDN web docs page for the<script>element when thedeferattribute is described:delphidabbler commentedon Nov 15, 2022
To get round this possible problem is to create a JavaScript file that loads last that calls code like
delphidabbler commentedon Nov 15, 2022
Useful web links:
async,deferetc