Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 9dc5f3e

Browse files
committed
minor fixes
1 parent 3efe4cf commit 9dc5f3e

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

‎2-ui/5-loading/02-script-async-defer/article.md‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,12 @@ Async scripts are great when we integrate an independent third-party script into
133133
<script async src="https://google-analytics.com/analytics.js"></script>
134134
```
135135

136+
```smart header="The `async` attribute is only for external scripts"
137+
Just like `defer`, the `async` attribute is ignored if the `<script>` tag has no `src`.
138+
```
139+
136140
## Dynamic scripts
137-
141+
138142
There's one more important way of adding a script to the page.
139143
140144
We can create a script and append it to the document dynamically using JavaScript:
@@ -188,7 +192,7 @@ But there are also essential differences between them:
188192
| `async` | *Load-first order*. Their document order doesn't matter -- which loads first runs first | Irrelevant. May load and execute while the document has not yet been fully downloaded. That happens if scripts are small or cached, and the document is long enough. |
189193
| `defer` | *Document order* (as they go in the document). | Execute after the document is loaded and parsed (they wait if needed), right before `DOMContentLoaded`. |
190194

191-
In practice, `defer` is used for scripts that need the whole DOM and/or their relative execution order is important.
195+
In practice, `defer` is used for scripts that need the whole DOM and/or their relative execution order is important.
192196

193197
And `async` is used for independent scripts, like counters or ads. And their relative execution order does not matter.
194198

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /