DEV Community

Faiz Mansuri
Faiz Mansuri

Posted on

How Web Pages Load?

I’ve been revisiting some fundamentals around script loading and wanted to share a simple visual that clarifies how script placement and attributes impact page performance:

🟒 HTML Parsing
πŸ”΅ Script Download
πŸ”΄ Script Execution

─────────────────────────────────────────────────────────────

1️⃣ <​script> in


HTML: 🟒🟒 πŸ”΄ 🟒🟒🟒
Script: πŸ”΅πŸ”΄
Parsing stops while the script downloads and runs.
This can delay rendering and hurt perceived performance.

─────────────────────────────────────────────────────────────

2️⃣ <​script> at end of


HTML: 🟒🟒🟒🟒🟒🟒
Script: ------------πŸ”΅πŸ”΄
HTML finishes parsing before the script loads and executes.
A safer default for avoiding render-blocking.

─────────────────────────────────────────────────────────────

3️⃣ <​script async>
HTML: 🟒🟒🟒🟒🟒🟒
Script: πŸ”΅---πŸ”΄
Downloads in parallel and executes as soon as it’s ready.
Can interrupt parsing unpredictably.

─────────────────────────────────────────────────────────────

4️⃣ <​script defer>
HTML: 🟒🟒🟒🟒🟒🟒
Script: πŸ”΅---------------πŸ”΄
Downloads in parallel and executes after parsing is complete.
Predictable and non-blocking.

Even small adjustments here can improve metrics like First Contentful Paint and make your site feel faster.

Top comments (0)