
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
preload-css-webpack-plugin
Advanced tools
Preload css plugin is an add-on for html-webpack-plugin. Inspired by Filament Group's LoadCSS. Plays nicely with multiple html-wepack-plugins and commons chunks plugin
This module requires html-webpack-plugin and extract-text-webpack-plugin to work. The plugin must be called after those two in your webpack configuration.
Install with npm or yarn.
$ npm install --save-dev preload-css-webpack-plugin
yarn add -D preload-css-webpack-plugin
Require it in your webpack configuration:
const PreloadCssPlugin = require("preload-css-webpack-plugin");
Add it to your Webpack plugins array after HtmlWebpackPlugin and ExtractTextPlugin:
plugins: [
new HtmlWebpackPlugin(),
new ExtractTextPlugin("[name].css"),
new PreloadCssPlugin()
]
The plugin assumes that all css assets should be preloaded. It converts your style link from
<link rel="stylesheet" href="style.css">
to the following
<link rel="preload" href="style.css" as="style" onload="this.rel='stylesheet'"><noscript><link rel="stylesheet" href="style.css"></noscript>
This transformation is based on what Filament Group has found has best asynchronous behavior. Since support for preload is pretty limited, I highly recommend that you include Filament Groups polyfill.
Preload Css plugin offers two options at this point in time.
| Name | Type | Default | Description |
|---|---|---|---|
blacklist | {Array} | [/\.map/] | Allows for excluding files from being asynchronously loaded. Accepts regex pattern or string. |
noscript | {Boolean} | True | Indicates whether or not to include noscript snippet on dom |
linkEventHandlers | {Object} | {onload: "this.onload=null;this.rel='stylesheet'"} | Modifies self to become a stylesheet after loading. This default value is provided by Filament Group. You can leverage any link event handlers you think are necessary, as defined by W3C spec. This is merged using lodash, you may set your settings to only have onerror and it'll join onload. |
plugins: [
new HtmlWebpackPlugin(),
new ExtractTextPlugin("[name].css"),
new PreloadCssPlugin({
blacklist: [/\.map/],
noscript: true,
linkEventHandlers: {
onload: "this.onload=null;this.rel='stylesheet'"
}
})
]
Feel free to Fork and Clone Repository. npm install <file> or npm link then start contributing!
Before PR's please run unit tests, npm run test make sure that all tests pass.
FAQs
An addon for html-webpack-plugin
The npm package preload-css-webpack-plugin receives a total of 8 weekly downloads. As such, preload-css-webpack-plugin popularity was classified as not popular.
We found that preload-css-webpack-plugin 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
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.