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
Copy file name to clipboardExpand all lines: 2-ui/5-loading/02-script-async-defer/article.md
+5-2Lines changed: 5 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -188,8 +188,11 @@ But there are also essential differences between them:
188
188
|`defer`|*Document order* (as they go in the document). | Execute after the document is loaded and parsed (they wait if needed), right before `DOMContentLoaded`. |
189
189
190
190
```warn header="Page without scripts should be usable"
191
-
Please note that if you're using `defer`, then the page is visible before the script loads and enables all the graphical components.
191
+
Please note that if you're using `defer`, then the page is visible *before* the script loads.
192
192
193
-
So, buttons should be disabled by CSS or by other means, to let the user
193
+
So the user may read the page, but some graphical components are probably not ready yet.
194
+
195
+
There should be "loading" indication in proper places, not-working buttons disabled, to clearly show the user what's ready and what's not.
196
+
```
194
197
195
198
In practice, `defer` is used for scripts that need the whole DOM and/or their relative execution order is important. And `async` is used for independent scripts, like counters or ads. And their relative execution order does not matter.
0 commit comments