Course contentsShow
← Web Development
Lesson 1975 of 2,98236. Performance Optimization TechniquesFree lesson

Extracting Critical CSS Manually

Learn how to manually identify and extract critical styles by analyzing viewport-visible content.

Extracting Critical CSS Manually

What you'll learn: How to manually identify and extract the CSS rules needed to render your page's visible content without scrolling.

Now that you can identify which styles are critical, you need to actually extract them from your full stylesheets into a separate, inlined critical CSS block.

The Manual Extraction Process

Think of your stylesheet like a toolbox. You need to pull out only the exact tools required to build what's visible in the viewport, leaving the rest for later delivery.

Step-by-step approach:

  1. Open your site in a browser at the target viewport size (typically 1366×768 desktop, 375×667 mobile)
  2. Inspect every visible element using DevTools, noting which CSS rules are actually applied
  3. Copy those specific rules into a new file or <style> block
  4. Include only the selectors actively styling visible content — skip :hover, media queries for other sizes, and styles for below-the-fold elements
  5. Test by inlining this CSS in your <head> and temporarily removing external stylesheets

Common Pitfalls

  • Over-extraction: Including too much CSS defeats the purpose. Be ruthless — only viewport-visible styles count
  • Missing dependencies: Some elements might rely on parent container styles that aren't obviously visible
  • Dynamic content: Consider different page states (logged-in vs out, loading states)

When Manual Works Best

Manual extraction is ideal for static sites, landing pages, or when you need complete control. For larger applications, you'll eventually want automated tools, but understanding the manual process teaches you exactly what "critical" means.

Key Takeaway: Manually extracting critical CSS means carefully identifying and copying only the styles that render visible above-the-fold content, creating a minimal inline stylesheet that eliminates render-blocking CSS for your initial viewport.