我有React应用程序,可以在主页上渲染很多图像。
而且我已经做了一些改进:
react-lazy-load-image-component
。lazy
,Suspense
用于反应路线。 config.plugins.push(new CompressionPlugin({
filename: '[path].gz[query]',
algorithm: 'gzip',
test: /\.(js|css|html|svg)$/,
threshold: 8192,
minRatio: 0.8
}))
config.plugins.push(new BrotliPlugin({
asset: '[path].br[query]',
test: /\.(js|css|html|svg)$/,
threshold: 10240,
minRatio: 0.8
}))
测试是在匿名浏览器窗口中进行的。使用:
yarn build --profile
serve -s build
两个主要观察结果:
灯塔会尽力指出细节,因此,如果要在类似生产环境中运行它(如果您选择这样做),我建议您仔细阅读其他部分,点击“了解更多”链接,以防万一,使您感到困惑,并根据Lighthouse提供的建议查看可以在何处进一步优化。
希望有帮助!