prefetch-polyfill-webpack-plugin
Intro
This plugin automatically wire up your async thunks with a prefetch polyfill function(using new Image().src or <script async>
) for platform which doesn't support <link rel='prefetch'>
, such as safari, to improve load time.
This is an extension plugin for html-webpack-plugin.
The prefetch polyfill function will be injected before </body>
.
<!-- as default it use new Image().src --> <!-- you can choose to use <script async> -->
Install
npm install prefetch-polyfill-webpack-plugin --save-dev
Usage
In webpack config, require the plugin:
const PrefetchPolyfillPlugin = ;
and add this plugin after HtmlWebpackPlugin:
plugins:
This plugin works well with preload-webpack-plugin. If you are using code splitting you are recommended to use both plugin at the same time.
options
mode
Set mode to async
to use <script async>
to prefetch, or use new Image().src
as default.
plugins: mode: 'async'
Acknowledgment
LICENSE
MIT