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 e7f898f2..ade6c0c7 100644 --- a/2-ui/5-loading/02-script-async-defer/article.md +++ b/2-ui/5-loading/02-script-async-defer/article.md @@ -3,11 +3,11 @@ In modern websites, scripts are often "heavier" than HTML: their download size is larger, and processing time is also longer. -When the browser loads HTML and comes across a `` tag, it can't continue building DOM. It must execute the script right now. The same happens for external scripts ``: the browser must wait until the script downloads, execute it, and only after process the rest of the page. +When the browser loads HTML and comes across a `` tag, it can't continue building the DOM. It must execute the script right now. The same happens for external scripts ``: the browser must wait until the script downloads, execute it, and only after process the rest of the page. That leads to two important issues: -1. Scripts can't see DOM elements below them, so can't add handlers etc. +1. Scripts can't see DOM elements below them, so it can't add handlers etc. 2. If there's a bulky script at the top of the page, it "blocks the page". Users can't see the page content till it downloads and runs: ```html run height=100 @@ -31,7 +31,7 @@ There are some workarounds to that. For instance, we can put a script at the bot 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 use far-from-perfect mobile internet. +Such things are invisible for people using very fast connections, but many people in the world still have slow internet speeds and use far-from-perfect mobile internet. Luckily, there are two `