1)路由懒加载
    2)vue-cli开启打包压缩 和后台配合 gzip访问
    3)进行cdn加速
    4)开启vue服务渲染模式
    5)用webpack的externals属性把不需要打包的库文件分离出去,减少打包后文件的大小
    6)在生产环境中删除掉不必要的console.log

    1. plugins: [
    2. new webpack.optimize.UglifyJsPlugin({ //添加-删除console.log
    3. compress: {
    4. warnings: false,
    5. drop_debugger: true,
    6. drop_console: true
    7. },
    8. sourceMap: true
    9. }),

    7)开启nginx的gzip ,在nginx.conf配置文件中配置

    1. http { //在 http中配置如下代码,
    2. gzip on;
    3. gzip_disable "msie6";
    4. gzip_vary on;
    5. gzip_proxied any;
    6. gzip_comp_level 8; #压缩级别
    7. gzip_buffers 16 8k;
    8. #gzip_http_version 1.1;
    9. gzip_min_length 100; #不压缩临界值
    10. gzip_types text/plain application/javascript application/x-javascript text/css
    11. application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png;
    12. }

    8)添加loading效果,给用户一种进度感受

    1. <!DOCTYPE html>
    2. <html lang="en">
    3. <head>
    4. <meta charset="utf-8">
    5. <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
    6. <meta http-equiv="X-UA-Compatible" content="chrome=1"/>
    7. <link rel="icon" href="<%= BASE_URL %>favicon.ico">
    8. <link rel="stylesheet" type="text/css" href="//at.alicdn.com/t/font_1112431_q8oa3yvrwbh.css">
    9. <title>demo</title>
    10. <style>
    11. .spinner {
    12. margin: 100px auto;
    13. width: 50px;
    14. height: 60px;
    15. text-align: center;
    16. font-size: 10px;
    17. }
    18. .spinner > div {
    19. background-color: #FE3C71;
    20. height: 100%;
    21. width: 6px;
    22. display: inline-block;
    23. -webkit-animation: stretchDelay 1.2s infinite ease-in-out;
    24. animation: stretchDelay 1.2s infinite ease-in-out;
    25. }
    26. .spinner .rect2 {
    27. -webkit-animation-delay: -1.1s;
    28. animation-delay: -1.1s;
    29. }
    30. .spinner .rect3 {
    31. -webkit-animation-delay: -1.0s;
    32. animation-delay: -1.0s;
    33. }
    34. .spinner .rect4 {
    35. -webkit-animation-delay: -0.9s;
    36. animation-delay: -0.9s;
    37. }
    38. .spinner .rect5 {
    39. -webkit-animation-delay: -0.8s;
    40. animation-delay: -0.8s;
    41. }
    42. @-webkit-keyframes stretchDelay {
    43. 0%, 40%, 100% {
    44. -webkit-transform: scaleY(0.4)
    45. }
    46. 20% {
    47. -webkit-transform: scaleY(1.0)
    48. }
    49. }
    50. @keyframes stretchDelay {
    51. 0%, 40%, 100% {
    52. transform: scaleY(0.4);
    53. -webkit-transform: scaleY(0.4);
    54. }
    55. 20% {
    56. transform: scaleY(1.0);
    57. -webkit-transform: scaleY(1.0);
    58. }
    59. }
    60. </style>
    61. </head>
    62. <body>
    63. <noscript>
    64. <strong>We're sorry but demo doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
    65. </noscript>
    66. <div id="app">
    67. <div class="spinner">
    68. <div class="rect1"></div>
    69. <div class="rect2"></div>
    70. <div class="rect3"></div>
    71. <div class="rect4"></div>
    72. <div class="rect5"></div>
    73. </div>
    74. </div>
    75. <!-- built files will be auto injected -->
    76. </body>
    77. </html>

    其他loading样式: