
Security News
Static vs. Runtime Reachability: Insights from Latio’s On the Record Podcast
The Latio podcast explores how static and runtime reachability help teams prioritize exploitable vulnerabilities and streamline AppSec workflows.
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');
module.exports = {
mode: 'production',
entry: './src/index.js',
output: {
path: OUTPUT_DIR,
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 40 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
The Latio podcast explores how static and runtime reachability help teams prioritize exploitable vulnerabilities and streamline AppSec workflows.
Security News
The latest Opengrep releases add Apex scanning, precision rule tuning, and performance gains for open source static code analysis.
Security News
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.