explaingit

addyosmani/critical

Analysis updated 2026-06-24

10,178JavaScriptAudience · developerComplexity · 2/5Setup · easy

TLDR

A Node.js tool that extracts the CSS needed to render the visible part of a web page immediately and inlines it into the HTML, so browsers can display content instantly without waiting for full stylesheets to load.

Mindmap

mindmap
  root((Critical CSS))
    What it does
      Extract above-fold CSS
      Inline into HTML
      Defer remaining CSS
    Build integrations
      Node.js module
      Grunt plugin
      Webpack plugin
    Config options
      Viewport dimensions
      Multiple screen sizes
      Ignore specific rules
    Benefits
      Faster first paint
      Better PageSpeed scores
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Speed up a website's first visible render by inlining only the above-the-fold CSS and deferring the rest to load in the background.

USE CASE 2

Integrate critical CSS extraction into a Webpack build pipeline to automatically optimize pages on every production build.

USE CASE 3

Generate critical CSS for multiple viewport sizes at once to optimize performance for both mobile and desktop visitors.

USE CASE 4

Improve Google PageSpeed and Core Web Vitals scores by eliminating render-blocking CSS on key landing pages.

What is it built with?

JavaScriptNode.jsCSSHTML

How does it compare?

addyosmani/criticalpiebald-ai/claude-code-system-promptscmiscm/leonsans
Stars10,17810,17810,184
LanguageJavaScriptJavaScriptJavaScript
Setup difficultyeasyeasymoderate
Complexity2/51/52/5
Audiencedeveloperdeveloperdesigner

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · easy Time to first run · 30min

In plain English

This is a Node.js tool that improves how fast web pages appear to load for visitors. It does this by identifying the CSS styles needed to render the visible portion of a page immediately on arrival, then embedding those styles directly into the HTML. The rest of the CSS loads separately in the background. The problem it solves is common in web development: when a browser loads a page, it normally has to fetch and process all the site's CSS before displaying anything. If those stylesheets are large, the user sees a blank screen for a noticeable moment. Critical extracts only the styles affecting what is visible on first load, called above-the-fold content, and puts those styles inline in the HTML. The browser can then render that content immediately, making the page feel much faster. You configure it by providing an HTML file and your CSS, plus a viewport size that represents the screen dimensions you want to optimize for. It can handle multiple screen sizes at once, which is useful for sites that adapt their layout for phones, tablets, and desktop displays. There is also an option to ignore specific CSS rules, such as font-face declarations or rules containing background images, if you want to defer those separately. The tool integrates with common JavaScript build workflows. It works as a Node.js module you call in code, and there are also plugins for Grunt and Webpack. It returns the processed HTML and CSS either through callbacks, promises, or async/await syntax, fitting into whatever JavaScript style a project already uses. The output is typically modified HTML with the critical CSS embedded inside a style tag, plus a separate file containing the remaining non-critical CSS that loads later.

Copy-paste prompts

Prompt 1
Show me how to use the critical npm package in a Node.js script to extract and inline critical CSS for an HTML file with a 1300x900 viewport.
Prompt 2
I have a Webpack project. Show me how to add the critical CSS plugin to my webpack.config.js so pages are automatically optimized at build time.
Prompt 3
How do I configure the critical package to ignore @font-face rules when extracting critical CSS, and why would deferring those separately help?
Prompt 4
Write a Node.js script using the critical package that loops through all HTML files in a dist/ folder and inlines their critical CSS in place.
Prompt 5
Explain in plain English what above-the-fold CSS means and how inlining it makes a web page feel faster for visitors on slow connections.

Frequently asked questions

What is critical?

A Node.js tool that extracts the CSS needed to render the visible part of a web page immediately and inlines it into the HTML, so browsers can display content instantly without waiting for full stylesheets to load.

What language is critical written in?

Mainly JavaScript. The stack also includes JavaScript, Node.js, CSS.

How hard is critical to set up?

Setup difficulty is rated easy, with roughly 30min to a first successful run.

Who is critical for?

Mainly developer.

Open on GitHub → Explain another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.