Skip to content

Commit d1d0156

Browse files
committed
Preload fonts
1 parent 20e4535 commit d1d0156

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

build/webpack.config.prod.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ const {CleanWebpackPlugin} = require('clean-webpack-plugin');
55
const OptimizeCSSAssetsPlugin = require("optimize-css-assets-webpack-plugin");
66
const SriPlugin = require('webpack-subresource-integrity');
77
const HtmlWebpackPlugin = require("html-webpack-plugin");
8+
const PreloadWebpackPlugin = require('preload-webpack-plugin');
89
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
910

1011
module.exports = merge(config, {
@@ -38,6 +39,13 @@ module.exports = merge(config, {
3839
},
3940
plugins: [
4041
new CleanWebpackPlugin(),
42+
new PreloadWebpackPlugin({
43+
rel: 'preload',
44+
as: 'font',
45+
include: 'allAssets', // it's better to preload fonts, since browser can render the content in required format sooner, so it gives better UX
46+
fileWhitelist: [/\.woff2/i], // preload font wince it's required all the time https://developers.google.com/speed/pagespeed/insights/?url=https%3A%2F%2Fpychat.org%2F%23%2Fpainter
47+
48+
}),
4149
new HtmlWebpackPlugin({
4250
template: '../src/index.ejs',
4351
inject: false,

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@
8787
"npm-run-all": "4.1.5",
8888
"nyc": "15.1.0",
8989
"optimize-css-assets-webpack-plugin": "5.0.4",
90+
"preload-webpack-plugin": "3.0.0-beta.4",
9091
"sass": "1.26.11",
9192
"sass-loader": "10.0.2",
9293
"servor": "4.0.2",

yarn.lock

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10187,6 +10187,11 @@ preceptor-core@~0.10.0:
1018710187
log4js "1.1.1"
1018810188
underscore "1.7.0"
1018910189

10190+
preload-webpack-plugin@3.0.0-beta.4:
10191+
version "3.0.0-beta.4"
10192+
resolved "https://registry.yarnpkg.com/preload-webpack-plugin/-/preload-webpack-plugin-3.0.0-beta.4.tgz#b8a36046df3b4a1b61db55d92f1a5aebdb99d246"
10193+
integrity sha512-6hhh0AswCbp/U4EPVN4fbK2wiDkXhmgjjgEYEmXa21UYwjYzCIgh3ZRMXM21ZPLfbQGpdFuSL3zFslU+edjpwg==
10194+
1019010195
prelude-ls@^1.2.1:
1019110196
version "1.2.1"
1019210197
resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.2.1.tgz#debc6489d7a6e6b0e7611888cec880337d316396"

0 commit comments

Comments
 (0)