Skip to content

Commit 949da30

Browse files
authored
Merge pull request #360 from odsantos/update-en-page-dom-content-loaded
Update "Page: DOMContentLoaded..." files
2 parents a4caf82 + b2af245 commit 949da30

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

2-ui/5-loading/01-onload-ondomcontentloaded/article.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ The lifecycle of an HTML page has three important events:
99
Each event may be useful:
1010

1111
- `DOMContentLoaded` event -- DOM is ready, so the handler can lookup DOM nodes, initialize the interface.
12-
- `load` event -- additional resources are loaded, we can get image sizes (if not specified in HTML/CSS) etc.
12+
- `load` event -- external resources are loaded, so styles are applied, image sizes are known etc.
1313
- `beforeunload` event -- the user is leaving: we can check if the user saved the changes and ask them whether they really want to leave.
1414
- `unload` -- the user almost left, but we still can initiate some operations, such as sending out statistics.
1515

@@ -60,7 +60,7 @@ So DOMContentLoaded definitely happens after such scripts:
6060
```html run
6161
<script>
6262
document.addEventListener("DOMContentLoaded", () => {
63-
console.log("DOM ready!");
63+
alert("DOM ready!");
6464
});
6565
</script>
6666

@@ -88,7 +88,7 @@ But there's a pitfall. If we have a script after the style, then that script mus
8888
```html run
8989
<link type="text/css" rel="stylesheet" href="style.css">
9090
<script>
91-
// the script doesn't not execute until the stylesheet is loaded
91+
// the script doesn't execute until the stylesheet is loaded
9292
alert(getComputedStyle(document.body).marginTop);
9393
</script>
9494
```
@@ -149,12 +149,12 @@ window.addEventListener("unload", function() {
149149
```
150150

151151
- The request is sent as POST.
152-
- We can send not only a string, but also forms and other formats, as described in the chapter <info:fetch-basics>, but usually it's a stringified object.
152+
- We can send not only a string, but also forms and other formats, as described in the chapter <info:fetch>, but usually it's a stringified object.
153153
- The data is limited by 64kb.
154154

155155
When the `sendBeacon` request is finished, the browser probably has already left the document, so there's no way to get server response (which is usually empty for analytics).
156156

157-
There's also a `keepalive` flag for doing such "after-page-left" requests in [fetch](info:fetch-basics) method for generic network requests. You can find more information in the chapter <info:fetch-api>.
157+
There's also a `keepalive` flag for doing such "after-page-left" requests in [fetch](info:fetch) method for generic network requests. You can find more information in the chapter <info:fetch-api>.
158158

159159

160160
If we want to cancel the transition to another page, we can't do it here. But we can use another event -- `onbeforeunload`.
@@ -265,7 +265,7 @@ Here's a document with `<iframe>`, `<img>` and handlers that log events:
265265
266266
<iframe src="iframe.html" onload="log('iframe onload')"></iframe>
267267
268-
<img src="http://en.js.cx/clipart/train.gif" id="img">
268+
<img src="https://en.js.cx/clipart/train.gif" id="img">
269269
<script>
270270
img.onload = () => log('img onload');
271271
</script>

2-ui/5-loading/01-onload-ondomcontentloaded/readystate.view/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
[20] readyState:interactive
1010
[21] DOMContentLoaded
1111
[30] iframe onload
12-
[40] readyState:complete
1312
[40] img onload
13+
[40] readyState:complete
1414
[40] window onload
1515
-->
1616

0 commit comments

Comments
 (0)