1.1.2 • Published 2 years ago

html-prefetch-webpack-plugin v1.1.2

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

node npm GitHub forks GitHub stars GitHub issues GitHub last commit

Install

npm i html-prefetch-webpack-plugin -D
# or
yarn add html-prefetch-webpack-plugin -D

Example

before:

<!doctype html>
<html>

<head>
   <meta charset="utf-8">
   <title>Webpack App</title>
   <meta name="viewport" content="width=device-width,initial-scale=1">
   <script defer="defer" src="./main.025b57ab4efabca2e393.js"></script>
</head>

<body></body>

</html>

after:

<!doctype html>
<html>

<head>
    <meta charset="utf-8">
    <title>Webpack App</title>
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <script defer="defer" src="./main.025b57ab4efabca2e393.js"></script>
+    <link as="script" href="./big-file.e4cd65aaa70ad26eba0d.js" rel="prefetch">
</head>

<body></body>

</html>

webpack config

const HtmlPrefetchWebpackPlugin = require('html-prefetch-webpack-plugin')
   plugins:[
    new htmlWwebpackPlugin(),
+   new HtmlPrefetchWebpackPlugin({
+       rel:'prefetch',
+       include:['big-file']
+  })
   ]

options

key(键)value(值)Default(默认值)Description(备注)
rel'prefetch' or 'preload'nullSpecify the type
includestring[]nullChunk file names that need to be preread and preloaded