
Security News
Bun 1.2.19 Adds Isolated Installs for Better Monorepo Support
Bun 1.2.19 introduces isolated installs for smoother monorepo workflows, along with performance boosts, new tooling, and key compatibility fixes.
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 60 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
Bun 1.2.19 introduces isolated installs for smoother monorepo workflows, along with performance boosts, new tooling, and key compatibility fixes.
Security News
Popular npm packages like eslint-config-prettier were compromised after a phishing attack stole a maintainer’s token, spreading malicious updates.
Security News
/Research
A phishing attack targeted developers using a typosquatted npm domain (npnjs.com) to steal credentials via fake login pages - watch out for similar scams.