Performance: Head and body sections
MEDIUM IMPACT
This affects the critical rendering path by controlling when and how resources load and when content is displayed.
<head> <link rel="preload" href="styles.css" as="style"> <link rel="stylesheet" href="styles.css"> <script src="large-script.js" defer></script> </head> <body> <h1>Welcome</h1> </body>
<head> <script src="large-script.js"></script> <link rel="stylesheet" href="styles.css"> </head> <body> <h1>Welcome</h1> </body>
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Blocking scripts/styles in head | Minimal DOM nodes | Multiple reflows due to delayed styles | High paint cost due to late style application | [X] Bad |
| Preload CSS and defer scripts | Minimal DOM nodes | Single reflow after styles load | Lower paint cost with early style application | [OK] Good |