npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@nuxtjs/critters

v0.10.1

Published

Critical CSS for Nuxt

Readme

@nuxtjs/critters

npm version npm downloads Github Actions CI Codecov License

CSS optimization using beasties (formerly critters) for Nuxt

Features

  • Zero-configuration required
  • Stylesheets are compiled at build time, so no CSS parser or DOM is needed at runtime
  • Critical CSS automatically injected to page
  • Works with runtime SSR and Nitro prerendering

Quick setup

  1. Add @nuxtjs/critters dependency to your project
yarn add @nuxtjs/critters # or npm install @nuxtjs/critters
  1. Add @nuxtjs/critters to the modules section of nuxt.config.js
{
  modules: [
    '@nuxtjs/critters',
  ],
}

How it works

Nuxt has a number of ways to optimize your CSS in production:

  1. ✅ Nuxt uses cssnano in the build step to minify CSS rules
  2. 📦 You can enable purgecss to remove unused CSS rules from your bundle.
  3. ✅ with @nuxtjs/critters you can now extract CSS files and load them separately, just inlining the CSS necessary to render the page.

At build time the module compiles every CSS asset emitted by the client build into a compact plan with beasties/compiler, and embeds those plans in the server bundle. At request (or prerender) time a Nitro plugin runs the zero-dependency beasties/runtime processor over the rendered HTML, which scans the markup in a single pass and inlines only the rules that can match.

Because inlined component styles never become external CSS assets (and so can never be pruned), the module disables features.inlineStyles.

Options

You can override the @nuxtjs/critters defaults like this:

// nuxt.config.js
import { defineNuxtConfig } from 'nuxt'
export default defineNuxtConfig({
  modules: ['@nuxtjs/critters'],
  critters: {
    config: {
      // Default: 'media'
      preload: 'swap',
    },
  },
})

Supported config keys are the compiler's allowRules and exact, plus the runtime processor options: preload, noscriptFallback, keyframes, fonts, inlineFonts, preloadFonts, cache, inlineThreshold and minimumExternalSize.

Differences from classic beasties

Some options of the classic (per-request, DOM-based) beasties API have no equivalent in the compiler + runtime pipeline:

  • pruneSource — the runtime does not rewrite the external stylesheet, so rules that were inlined are still served by it.
  • path, publicPath, external, remote, additionalStylesheets, mergeStylesheets — stylesheets are taken from the client build's emitted assets rather than resolved from the filesystem or network.
  • reduceInlineStyles, compress, safeParser, logLevel, logger, dedupeWarnings — parsing, minification and diagnostics all happen at build time, and compiler warnings are reported through the Nuxt logger.

Two behaviours also differ:

  • minimumExternalSize is measured against the rules that were not inlined, i.e. what the external stylesheet would still need to provide, rather than against a rewritten external stylesheet.
  • cache defaults to being enabled only when the total compiled CSS is large enough that fingerprinting a document is cheaper than re-evaluating the plans. Set cache: true or cache: false to decide explicitly.

CSP nonces

The module reads the per-request nonce from event.context.security.nonce and applies it to the <style> and <script> elements it injects. With nuxt-security and its nonce support enabled, this needs no configuration.

It has to happen here rather than in the module that generates the nonce: nuxt-security stamps nonces onto rendered tags in Nitro's render:html hook, which runs before the render:response hook where critical CSS is inlined, so anything injected there is invisible to that pass. When the event carries no nonce — during prerendering, for instance — nothing is added.

beasties itself also accepts a nonce option, but it is not exposed here: a value fixed at build time is constant for the lifetime of the server, which defeats the point of a nonce.

Development

  1. Clone this repository
  2. Enable corepack with corepack enable
  3. Install dependencies using pnpm install
  4. Start development server using pnpm dev

License

MIT License