Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

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

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)05/31 Report--

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.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report