Skip to main content
GrN.dk

Main navigation

  • Articles
  • Contact
  • Your Digital Project Manager
  • About Greg Nowak
  • Services
  • Portfolio
  • Container
    • Excel Freelancer
    • Kubuntu - tips and tricks
    • Linux Apache MySQL and PHP
    • News
    • Image Gallery
User account menu
  • Log in

Breadcrumb

  1. Home

Critical CSS for Faster Pages

Critical CSS is the small slice of styling a browser needs to render the first visible part of a page. When a site ships one large stylesheet, the browser typically waits for that CSS before it paints meaningful content. That is why critical CSS still matters: done well, it helps users see a usable page sooner. Done badly, it creates brittle per-page hacks, broken asset paths, and a lot of maintenance for a marginal gain.

If you run a marketing site, a Drupal build, or a component-heavy front end, the practical question is not "should we use critical CSS because SEO likes speed?" The better question is: is render-blocking CSS one of the real bottlenecks on our most important pages? If the answer is yes, critical CSS is worth testing. If the bottleneck is actually server response time, an oversized hero image, or JavaScript, fix those first.

When Critical CSS Is Worth the Effort

Critical CSS is most useful when you have a large shared stylesheet and a clear set of high-value page templates such as homepage, landing pages, service pages, or campaign pages. In those cases, inlining the above-the-fold styles for each template can reduce the delay before the first meaningful render.

It is less useful when your CSS is already small, your pages are mostly cached, or each page is so unique that you would need a separate critical CSS file for hundreds of URLs. In that situation, CSS cleanup and bundle reduction often produce a better return with less complexity.

What Should Go Into the Critical Layer

The critical layer should cover only what is needed to render the first screen cleanly: layout, header, navigation, main hero block, basic typography, and any immediately visible buttons or forms. Keep it lean. Do not dump your whole design system into the page head.

I usually leave these out of the critical layer unless testing proves they matter:

  • Below-the-fold components such as accordions, sliders, testimonials, and footers.
  • Rarely used utility classes and admin or editor-facing styles.
  • Heavy background-image rules that are not part of the first visible experience.
  • Page-specific edge cases that can be loaded with the main stylesheet a moment later.

The point is not to win a synthetic score by a few points. The point is to get to a stable, credible first render faster.

Implementation That Does Not Turn Into a Maintenance Problem

For most teams, the cleanest approach is to generate critical CSS in the build pipeline, per template or page family, not manually and not from one-off online generators. Online tools are fine for a quick experiment, but they are a poor foundation for production work because rebased asset URLs, web fonts, logged-in states, and CMS variations are where things usually go wrong.

If your build runs on Node, the critical package is still a practical starting point:

pnpm add -D critical
import { generate } from "critical";

await generate({
  base: "dist/",
  src: "index.html",
  inline: true,
  target: {
    css: "critical.css",
    html: "index-critical.html"
  },
  dimensions: [
    { width: 390, height: 844 },
    { width: 1280, height: 900 }
  ]
});

That multi-viewport step matters. A mobile-only or desktop-only capture often misses layout rules that are essential on the other breakpoint. Also be careful with aggressive extraction options: page-specific "uncritical" CSS can reduce cache reuse across pages, which means you can win one metric and lose overall efficiency. Before rollout, test anonymous mobile pages in Lighthouse or PageSpeed Insights, then watch Search Console's Core Web Vitals reporting afterward.

If your global CSS bundle is simply too large, pair critical CSS with CSS cleanup. PurgeCSS is still useful here, especially on sites that carry years of legacy selectors. The catch is that CMS-driven or JavaScript-driven class names must be safelisted, otherwise you will remove selectors that only appear at runtime.

await new PurgeCSS().purge({
  content: ["templates/**/*.html", "src/**/*.js"],
  css: ["dist/app.css"],
  safelist: [/^is-/, /^has-/],
  rejected: true
});

The rejected: true output is worth reviewing during rollout. It is one of the simplest ways to catch over-pruning before it hits production.

Drupal-Specific Note

If you are on Drupal, the maintained critical_css module is still available and is installed with:

composer require 'drupal/critical_css:^2.0'

That can work well when the theme output is predictable and your critical CSS files are generated as part of a repeatable release process. For highly dynamic, editor-built pages, I would still treat critical CSS as a front-end build concern first and a Drupal delivery concern second.

How This Helps SEO and Conversion

Critical CSS can support SEO, but it is not a magic ranking trick. Google is explicit that good page experience and Core Web Vitals matter, while also being clear that strong scores alone do not guarantee top rankings. The business case is broader than SEO anyway: faster perceived load, cleaner first paint, and fewer jarring layout issues usually make pages easier to trust and easier to use.

For lead generation pages, that matters. If a prospect can read the headline, see the offer, and interact with the page without waiting through a blank or unstable first render, you reduce friction at the exact moment attention is fragile.

If you want help deciding whether critical CSS is worth the complexity on your site, or you need someone to audit the full front-end path instead of treating performance as a single-score exercise, Greg can help you scope the right fix.

Need help with this kind of work?

Need a practical review of CSS delivery, front-end performance, or Drupal theme workflow? Greg can help you scope the right fix. Get in touch with Greg.

Sources

  • Understand the critical path | web.dev
  • Understanding page experience in Google Search results | Google Search Central
  • addyosmani/critical | GitHub
  • Configuration | PurgeCSS
  • Critical CSS | Drupal.org
Last modified
2026-06-06

Tags

  • seo
  • Performance
  • css
  • Drupal

Review Greg on Google

Greg Nowak Google Reviews

 

  • Rewrite index.html and index.php to the Root URL in Apache
  • Critical CSS for Faster Pages
  • Unable to Post in WordPress? Fix the Invalid JSON Response Error
  • Cloudflare AI Gateway Spend Limits Make LLM Cost Control a Real Ops Project
  • Tidy Up composer.json with Composer Normalize
RSS feed

GrN.dk web platforms, web optimization, data analysis, data handling and logistics.