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

如下

upstream sems {
    server 127.0.0.1:10171 weight=1 fail_timeout=0;
}

server {
    listen 80;
    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 6; # 压缩比例,比例越大,压缩时间越长。默认是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的时候,可以按需加载使用到的组件

转载于:https://www.cnblogs.com/robinunix/p/11558904.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值