Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to solve the problem of slow opening speed of the first screen of vue project

Shulou Source: shulou.com Published: 2022-05-31 12:07:30 09月29日 Update

This article mainly introduces the vue project first screen opens slowly how to solve the relevant knowledge, the content is detailed and easy to understand, the operation is simple and fast, has a certain reference value, I believe that everyone after reading this vue project first screen open slowly how to solve the article will have a harvest, let's take a look.

First we need to install webpack-bundle-analyzer

/ / webpack.prod.conf.jsif (config.build.bundleAnalyzerReport) {const BundleAnalyzerPlugin = require ('webpack-bundle-analyzer'). BundleAnalyzerPlugin webpackConfig.plugins.push (new BundleAnalyzerPlugin ())} / / config/index.jsbuild: {/ / Run the build command with an extra argument to / / View the bundle analyzer report after build finishes: / / `npm run build-- report` / / Set to `true`or `false` to always turn it on or off bundleAnalyzerReport: process.env.npm_config_report}

Run npm run build-- report

We can see that the elementui in vendor accounts for 500k, how to optimize it?

Add it to the webpack configuration file, and then it's time to witness miracles.

Externals: {'vue':' Vue', 'element-ui':' ELEMENT', 'axios':' axios'}

Take a look at our vendor volume again.

The total vendor is only 195k.

Where can I find the missing elementui files? The answer is cdn citation.

There was a reference to moment in the project before, but this library is too big. I found a library exactly like momentapi on github, but the file size is only 2kb.

This is the end of the article on "how to solve the problem of slow opening of the first screen of the vue project". Thank you for reading! I believe that everyone has a certain understanding of the knowledge of "how to solve the slow opening speed of the first screen of the vue project". If you still want to learn more knowledge, you are welcome to follow the industry information channel.

Tags: Project speed file knowledge content article next value volume size miracle that is easy to operate article moment easy to understand more see answer industry Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MySQL MariaDB OPPO Reno Shulou Information Apple