Gathering detailed insights and metrics for html-prefetch-css-webpack-plugin
Gathering detailed insights and metrics for html-prefetch-css-webpack-plugin
Gathering detailed insights and metrics for html-prefetch-css-webpack-plugin
Gathering detailed insights and metrics for html-prefetch-css-webpack-plugin
npm install html-prefetch-css-webpack-plugin
Typescript
Module System
Node Version
NPM Version
36.5
Supply Chain
49.5
Quality
64.6
Maintenance
25
Vulnerability
96.4
License
JavaScript (94.3%)
HTML (3.73%)
CSS (1.97%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
3 Stars
15 Commits
3 Forks
1 Watchers
1 Branches
1 Contributors
Updated on May 03, 2019
Latest Version
0.1.3
Package Id
html-prefetch-css-webpack-plugin@0.1.3
Unpacked Size
19.66 kB
Size
5.80 kB
File Count
10
NPM Version
6.14.5
Node Version
12.13.0
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
1
2
1 npm i --save-dev html-prefetch-css-webpack-plugin
This is a webpack plugin, work with html-webpack-plugin. inject prefetch link to html head;
while use code spilting in webpack, we can use magic comment to mark module that we want to prefetch;
like this
1/* webpackPrefetch: true */
but the split css file won't be prefetched;
before load
1<head> 2 ... 3 <link rel="prefetch" href="example.js"> 4 ... 5</head>
after loaded
1<head> 2 ... 3 <link rel="prefetch" href="example.js"> 4 <link rel="stylesheet" type="text/css" href="example.css"> 5 <script charset="utf-8" src="example.js"></script> 6 ... 7</head>
although the js file be prefetched, css file still need to wait;
to solve this problem, we can use 'style-loader' to integrate css to js file;
webpack.config.js
1module.exports = { 2 ... 3 module: { 4 rules: [ 5 { 6 test: /css$/, 7 loaders: ['style-loader','css-loader'] 8 } 9 ] 10 } 11 ... 12}
else use this plugin
before load
1<head> 2 ... 3 <link rel="prefetch" href="example.css"> 4 <link rel="prefetch" href="example.js"> 5 ... 6</head>
index.js
1const button = document.createElement("button"); 2button.innerText = "lazy load btn"; 3button.addEventListener("click", () => { 4 // use magic comments to mark module need be prefetch 5 // webpack 4.6.0+ support 6 import(/* webpackChunkName: "lazy" */ /* webpackPrefetch: true */ "./lazy.js").then( 7 module => { 8 document.body.appendChild(module.default("<h2>Lazy load Content</h2>")); 9 } 10 ); 11}); 12document.body.appendChild(button);
lazy.js
1import "./lazy.css"; 2 3export default content => { 4 const lazy = document.createElement("div"); 5 lazy.classList.add("lizy"); 6 lazy.innerHTML = content; 7 return lazy; 8};
lazy.css
1.lazy { 2 font-size: 20px; 3 color: red; 4}
webpack.config.js
1const HtmlWebpackPlugin = require("html-webpack-plugin"); 2 3const MiniCSSExtractPlugin = require("mini-css-extract-plugin"); 4 5const PrefetchCssWebpackPlugin = require("html-prefetch-css-webpack-plugin"); 6 7module.export = { 8 entry: "index.js", 9 output: { 10 path: __dirname + "/dist", 11 filename: "index.bundle.js" 12 }, 13 module: { 14 rules: [ 15 { 16 test: /\.css$/, 17 use: [MiniCSSExtractPlugin.loader, "css-loader"] 18 } 19 ] 20 }, 21 plugins: [ 22 new HtmlWebpackPlugin(), 23 new PrefetchCssWebpackPlugin(), 24 new MiniCSSExtractPlugin("[name].css") 25 ] 26};
the generated html file would be
1<!DOCTYPE html> 2<html> 3 <head> 4 <meta charset="UTF-8"> 5 <title>Webpack App</title> 6 <link rel="prefetch" href="lazy.css"> 7 </head> 8 <body> 9 <script src="index_bundle.js"></script> 10 </body> 11</html>
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
Found 0/15 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no SAST tool detected
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
license file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
129 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More