
Security News
US Government Forces Anthropic to Pull Claude Fable Days After Launch
Anthropic says the directive cited national security concerns over a narrow jailbreak, but offered no specific technical details.
@opensourceframework/critters
Advanced tools
Inline critical CSS and lazy-load the rest. Forked from GoogleChromeLabs/critters.
Inline critical CSS and lazy-load the rest for faster page loads
This is a maintained fork of the original critters package by GoogleChromeLabs.
The original critters package was archived by GoogleChromeLabs in October 2024. This fork continues maintenance to ensure the package remains available and up-to-date for the community.
This package is a fork of GoogleChromeLabs/critters, originally created by:
Original source code is Copyright 2018 Google LLC and licensed under the Apache License, Version 2.0.
npm install @opensourceframework/critters
# or
yarn add @opensourceframework/critters
# or
pnpm add @opensourceframework/critters
import Critters from '@opensourceframework/critters';
const critters = new Critters({
path: '/path/to/public',
publicPath: '/'
});
const html = `
<html>
<head>
<link rel="stylesheet" href="/style.css">
</head>
<body>
<h1>Hello World!</h1>
</body>
</html>
`;
const processedHtml = await critters.process(html);
// webpack.config.js
const Critters = require('@opensourceframework/critters');
module.exports = {
// ...
plugins: [
new Critters({
// Options
preload: 'swap',
pruneSource: false,
reduceInlineStyles: true
})
]
};
// next.config.js
const Critters = require('@opensourceframework/critters');
module.exports = {
webpack: (config, { dev }) => {
if (!dev) {
config.plugins.push(
new Critters({
preload: 'swap'
})
);
}
return config;
}
};
| Option | Type | Default | Description |
|---|---|---|---|
path | string | process.cwd() | Base path for resolving stylesheets |
publicPath | string | '' | Public URL prefix for stylesheets |
external | boolean | false | Only inline styles from additionalStylesheets |
additionalStylesheets | string[] | [] | Additional stylesheets to inline |
preload | string | 'swap' | Preload strategy: 'swap', 'media', 'js', 'js-lazy', 'body', or 'none' |
noscriptFallback | boolean | true | Add <noscript> fallback for preloaded stylesheets |
inlineThreshold | number | 0 | Inline stylesheets smaller than this size (bytes) |
minimumExternalSize | number | 0 | Minimum size for external stylesheets |
pruneSource | boolean | false | Remove inlined rules from external stylesheet |
mergeStylesheets | boolean | true | Merge multiple stylesheets into one |
additionalStylesheets | string[] | [] | Fetch additional stylesheets not in the HTML |
reduceInlineStyles | boolean | true | Reduce inline styles |
loadFonts | boolean | true | Preload critical fonts |
logger | object | null | Custom logger instance |
swap (default): Uses <link rel="preload"> to load CSS asynchronouslymedia: Uses media attribute trick to load CSS asynchronouslyjs: Uses JavaScript to load CSS asynchronouslyjs-lazy: Uses JavaScript with requestAnimationFrame for lazy loadingbody: Appends stylesheet to body for async loadingnone: No preloading, just inlines critical CSSCritters extracts critical CSS by:
Control which CSS gets inlined using special comments:
/* critters:exclude */
.always-external { color: red; }
/* critters:include */
.always-inlined { color: blue; }
/* critters:include start */
.included-rule-1 { color: green; }
.included-rule-2 { color: yellow; }
/* critters:include end */
critters:exclude - Never inline these rulescritters:include - Always inline these rules (even if not matched)critters:include start / critters:include end - Include a block of rulescrittersIf you were using the original critters package, migrating is straightforward:
- import Critters from 'critters';
+ import Critters from '@opensourceframework/critters';
- const critters = new Critters(options);
+ const critters = new Critters(options);
The API is fully compatible with the original package. Simply replace the package name in your dependencies and imports.
new Critters(options)Creates a new Critters instance.
critters.process(html)Processes HTML and returns the result with inlined critical CSS.
html (string): The HTML to processPromise<string> - The processed HTMLcritters.readFile(filename)Reads a stylesheet file. Override this method to customize file reading.
filename (string): The path to the stylesheetstring | undefined - The CSS contentThis package includes protections against:
We welcome contributions! Please see our Contributing Guide for details.
Apache-2.0 © Google LLC
This fork is maintained by the OpenSource Framework Contributors.
FAQs
Embedded CSS critical path extraction for Next.js applications
The npm package @opensourceframework/critters receives a total of 21 weekly downloads. As such, @opensourceframework/critters popularity was classified as not popular.
We found that @opensourceframework/critters demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Anthropic says the directive cited national security concerns over a narrow jailbreak, but offered no specific technical details.

Security News
A network of 152 Chrome live wallpaper extensions hid ad tracking and made extension-driven traffic look like Google search clicks.

Company News
Socket’s first CISO brings deep experience securing high-growth SaaS companies as open source supply chain threats accelerate.