vue chunk-elementUI.3d5a4739.js 过大,网页打开慢开启gzip压缩

2022-12-02,,,,

如下

upstream sems {
server 127.0.0.1: weight= fail_timeout=;
} server {
listen ;
server_name www.serve.com; location / {
proxy_pass http://sems/dist/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; gzip on; # 注意是在当前的访问域名下开启有效
gzip_comp_level ; # 压缩比例,比例越大,压缩时间越长。默认是1
gzip_types text/xml text/plain text/css application/javascript application/x-javascript application/rss+xml image/jpeg image/gif image/png; # 哪些文件可以被压缩
gzip_disable "MSIE [1-6]\."; # IE6无效
} }

如果没有效果,检查看header信息,发现发现Content-Type项的“application/javascript”并没有出现在他的gzip_types内容里.所以把这个添加到gzip_types中,js也可以压缩成功了

其他优化方案,参考https://www.jianshu.com/p/16a6db7d50a7

去掉多余的库 npm uninstall xxx

路由懒加载

将文件放到cdn上

另外参考 https://blog.csdn.net/nailgo/article/details/90599656 在使用element-ui的时候,可以按需加载使用到的组件

vue chunk-elementUI.3d5a4739.js 过大网页打开慢开启gzip压缩的相关教程结束。

《vue chunk-elementUI.3d5a4739.js 过大,网页打开慢开启gzip压缩.doc》

下载本文的Word格式文档,以方便收藏与打印。