Webpack plugin that inlines critical CSS and lazy-loads the rest. v3.0.2 is current, based on Critters 0.0.16. It uses JSDOM and css-select for processing, no headless browser, making it fast and lightweight. Supports html-webpack-plugin v4, preload options, font inlining, and pruning of unused keyframes. Differentiators: speed (no browser), integrates seamlessly with webpack-dev-server, and complements prerender-loader for SPA SSR. Release cadence is irregular.
npm install critters-webpack-pluginVerified import paths — ran on the pinned version, not inferred.
Shows basic setup of Critters with HtmlWebpackPlugin, using preload swap mode and font preloading.
Upgrade to v3.x. If stuck on 1.x, use `legacy` dist tag.
Review inlined CSS output after upgrading. Check for :where selector support added in 0.0.16.
Use `require('critters-webpack-plugin')` in webpack config. Do not use `import`.Install html-webpack-plugin: npm i -D html-webpack-plugin
Use `additionalStylesheets` option if using standalone Critters, or keep using `includeMatchingStylesheets`.
npm install html-webpack-plugin --save-dev
Replace `import Critters from 'critters-webpack-plugin'` with `const Critters = require('critters-webpack-plugin')`Ensure html-webpack-plugin is installed and added before Critters in plugins array