Skip to main content
Brave Programmer Logo

BraveProgrammer

BraveProgrammer

HomeProjectsBlogsCoursesLessonsAbout

Site footer

BraveProgrammer

Free coding courses, practical tutorials, and real projects from BraveProgrammer. Learn web development with React, Next.js, and TypeScript.

Navigation

  • Home
  • Projects
  • Blogs
  • Courses

Resources

  • About
  • Lessons

© 2026 BraveProgrammer. All rights reserved.

  1. Courses
  2. /
  3. CSS Basics to Advanced

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 to rel="stylesheet" on onload.

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>
Previous: CSS for EmailNext: CSS Architecture – BEM, OOCSS, SMACSS, ITCSS