FE Lead prep · ref 02
<script> → fetch → parse+compile → execute, then parsing resumes. Parser-blocking; also waits on pending CSSOM (may read computed styles).display:none excluded; visibility:hidden stays.transform, opacity. Animating width/top forces reflow.| Resource | Blocks | Why | Fix |
|---|---|---|---|
| CSS | rendering (render tree) | rules cascade → can't paint till CSSOM complete | inline critical CSS, load rest non-blocking |
| Sync JS | the parser (DOM) | can mutate DOM; also waits on pending CSS (may read styles) | defer / async, code-split |
| async | defer | |
|---|---|---|
| download | parallel | parallel |
| executes | ASAP on arrival | after parse, pre-DCL |
| order kept | NO | YES |
| use for | independent tags | app / ordered code |
defer/async.”Sources: web.dev — critical path · MDN — CRP · MDN — <script> · web.dev — render tree
getComputedStyle.async = no order guarantee → only for independent scripts. Ordered code → defer.transform/opacity (composite), never width/top (reflow).