vue优化之加快首屏加载速度

一、依赖优化之 CDN 加速
减少app.js和vender.js的体积,加快加载速度
二、gzip暴力压缩
1.npm安装
npm i [email protected] --save-dev
2.配置,config里的index.js文件

 build: {
    // Gzip off by default as many popular static hosts such as
   	// Surge or Netlify already gzip all static assets for you.
   	// Before setting to `true`, make sure to:
   	// npm install --save-dev compression-webpack-plugin
   	productionGzip: true,      //设置为true,之前时false  改为true
   	productionGzipExtensions: ['js', 'css'],
 }

三、路由懒加载

{
      path: '/list',
      name: 'list',
      component:resolve => require(["@/components/list"],resolve)
    },

你可能感兴趣的:(vue)