diff --git a/2-ui/5-loading/02-script-async-defer/article.md b/2-ui/5-loading/02-script-async-defer/article.md index 2031ec07..b3e4892b 100644 --- a/2-ui/5-loading/02-script-async-defer/article.md +++ b/2-ui/5-loading/02-script-async-defer/article.md @@ -29,11 +29,11 @@ There are some workarounds to that. For instance, we can put a script at the bot
- - - - - Leave for EXAMPLE.COM -``` -But this solution is far from perfect. For example, the browser actually notices the script (and can start downloading it) only after it downloaded the full HTML document. For long HTML documents, that may be a noticeable delay. +But this solution is far from perfect. For example, the browser notices the script (and can start downloading it) only after it downloaded the full HTML document. For long HTML documents, that may be a noticeable delay. -Such things are invisible for people using very fast connections, but many people in the world still have slower internet speeds and far-from-perfect mobile connectivity. +Such things are invisible for people using very fast connections, but many people in the world still have slower internet speeds and use far-from-perfect mobile internet. -Luckily, there are two ` ``` ## Dynamic scripts -We can also create a script dynamically using JavaScript: +We can also add a script dynamically using JavaScript: ```js run let script = document.createElement('script'); @@ -145,7 +146,7 @@ That is: - They don't wait for anything, nothing waits for them. - The script that loads first -- runs first ("load-first" order). -We can change the load-first order into the document order by explicitly setting `async` to `false`: +We can change the load-first order into the document order (just like regular scripts) by explicitly setting `async` property to `false`: ```js run let script = document.createElement('script'); @@ -191,7 +192,4 @@ Please note that if you're using `defer`, then the page is visible before the sc So, buttons should be disabled by CSS or by other means, to let the user -In practice, `defer` is used for scripts that need DOM and/or their relative execution order is important. - - -So `async` is used for independent scripts, like counters or ads, that don't need to access page content. And their relative execution order does not matter. +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. diff --git a/2-ui/5-loading/02-script-async-defer/window-onbeforeunload.view/index.html b/2-ui/5-loading/02-script-async-defer/window-onbeforeunload.view/index.html deleted file mode 100644 index eacfda1f..00000000 --- a/2-ui/5-loading/02-script-async-defer/window-onbeforeunload.view/index.html +++ /dev/null @@ -1,19 +0,0 @@ - - -
- - -
-