Lesson 38 of 50 · css
CSS Performance – Critical CSS & Unused CSS
Duration: 9 mins
Critical CSS is the minimal set of styles needed for above‑the‑fold content.
- Extract it manually or with tools like Critical, PurgeCSS, UnCSS.
- Inline critical CSS in the
<head>to avoid a render‑blocking request. - Load the rest of the stylesheet with
rel="preload"+as="style"and change torel="stylesheet"ononload.
Example: Inline critical CSS + preload
<style>
.hero{background:#333;color:#fff;padding:4rem;text-align:center;}
</style>
<link rel="preload" href="/css/main.css" as="style" onload="this.rel='stylesheet'">
<noscript><link rel="stylesheet" href="/css/main.css"></noscript>