
Security News
Browserslist-rs Gets Major Refactor, Cutting Binary Size by Over 1MB
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
webpack-critical-css-inliner
Advanced tools
A fast webpack plugin for inlining critical (above-the-fold) css
It is a webpack plugin that inlines your critical (above-the-fold) CSS using Puppeteer.
Webpack-critical-css-inliner uses critical-css-inliner under the hood, so IT IS VERY FAST.
If you use ADAPTIVE DESIGN, webpack-critical-css-inliner is your salvation. It supports both mobile and desktop versions.
npm install --save-dev webpack-critical-css-inliner
// or
yarn add --dev webpack-critical-css-inliner
webpack.config.js
const WebpackCriticalCSSInliner = require('webpack-critical-css-inliner');
module.exports = {
plugins: [
new WebpackCriticalCSSInliner({
// Your entrypoint
base: 'dist/',
// HTML source file
src: 'index.html',
// HTML target file
target: 'index-critical.html',
// Add Google Fonts to critical CSS
inlineGoogleFonts: true,
// Minify all styles
minify: true,
// ignore styles from the following stylesheets
ignoreStylesheets: [/bootstrap/],
// inline styles with the following CSS rules
whitelist: /#foo|\.bar/
})
]
}
// webpack.config.js
const WebpackCriticalCSSInliner = require('webpack-critical-css-inliner');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const path = require('path');
module.exports = {
mode: 'production',
entry: path.resolve(__dirname, 'src/', 'index.js'),
output: {
path: path.resolve(__dirname, 'dist/'),
filename: 'webpack-critical-css-inliner.[contenthash].js'
},
module: {
rules: [{
test: /\.css$/,
use: [
MiniCssExtractPlugin.loader,
'css-loader'
]
}]
},
plugins: [
new HtmlWebpackPlugin(),
new MiniCssExtractPlugin(),
new WebpackCriticalCSSInliner({
base: 'dist/',
src: 'index.html',
target: 'index-critical.html',
inlineGoogleFonts: true,
minify: true,
ignoreStylesheets: [/bootstrap/],
whitelist: /#foo|\.bar/
})
]
}
MIT license
FAQs
A fast webpack plugin for inlining critical (above-the-fold) css
The npm package webpack-critical-css-inliner receives a total of 43 weekly downloads. As such, webpack-critical-css-inliner popularity was classified as not popular.
We found that webpack-critical-css-inliner demonstrated a not healthy version release cadence and project activity because the last version was released 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
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
Research
Security News
Eight new malicious Firefox extensions impersonate games, steal OAuth tokens, hijack sessions, and exploit browser permissions to spy on users.
Security News
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.