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
+4-4Lines changed: 4 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -37,7 +37,7 @@ Luckily, there are two `<script>` attributes that solve the problem for us: `def
37
37
38
38
## defer
39
39
40
-
The `defer` attribute tells the browser not to wait for the script. Instead, the browser will continue to process the HTML, build DOM. The script loads "in the background", and then runs when the DOM is fully built.
40
+
The `defer` attribute tells the browser not to wait for the script. Instead, the browser will continue to process the HTML, build DOM. The script loads "in the background", and then runs when the DOM is fully built.
41
41
42
42
Here's the same example as above, but with `defer`:
43
43
@@ -97,13 +97,13 @@ The `async` attribute is somewhat like `defer`. It also makes the script non-blo
97
97
98
98
The `async` attribute means that a script is completely independent:
99
99
100
-
- The browser doesn't block on `async` scripts (like `defer`).
101
-
- Other scripts don't wait for `async` scripts, and `async` scripts don't wait for them.
100
+
- The browser doesn't block on `async` scripts (like `defer`).
101
+
- Other scripts don't wait for `async` scripts, and `async` scripts don't wait for them.
102
102
- `DOMContentLoaded` and async scripts don't wait for each other:
103
103
- `DOMContentLoaded` may happen both before an async script (if an async script finishes loading after the page is complete)
104
104
- ...or after an async script (if an async script is short or was in HTTP-cache)
105
105
106
-
In other words, `async` scripts load in the background and run when ready. The DOM and other scripts don't wait for them, and they don't wait for anything. A fully independent script that runs when loaded. As simple, at it can get, right?
106
+
In other words, `async` scripts load in the background and run when ready. The DOM and other scripts don't wait for them, and they don't wait for anything. A fully independent script that runs when loaded. As simple, at it can get, right?
107
107
108
108
Here's an example similar to what we've seen with `defer`: two scripts `long.js` and `small.js`, but now with `async` instead of `defer`.
0 commit comments