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)