Coder Social home page Coder Social logo

第41题(2019-09-17):vue 如何优化首页的加载速度?vue 首页白屏是什么问题引起的?如何解决呢? about interview HOT 1 OPEN

qappleh avatar qappleh commented on June 22, 2024
第41题(2019-09-17):vue 如何优化首页的加载速度?vue 首页白屏是什么问题引起的?如何解决呢?

from interview.

Comments (1)

qappleh avatar qappleh commented on June 22, 2024

首先分析原因
VUE首页加载过慢,其原因是因为它是一个单页应用,需要将所有需要的资源(比如app.js vendor.js)都下载到浏览器端并解析,所以当网速差的时候会产生一定程度的白屏。

考虑解决办法
1.使用首屏SSR + 跳转SPA方式来优化
2.改单页应用为多页应用,需要修改webpack的entry
3.改成多页以后使用应该使用prefetch的就使用
4.处理加载的时间片,合理安排加载顺序,尽量不要有大面积空隙
5.CDN资源还是很重要的,最好分开,也能减少一些不必要的资源损耗
6.使用Quicklink,在网速好的时候 可以帮助你预加载页面资源
7.骨架屏这种的用户体验的东西一定要上,最好借助stream先将这部分输出给浏览器解析
8.合理使用web worker优化一些计算
9.缓存一定要使用,但是请注意合理使用
10.大概就这么多,最后可以借助一些工具进行性能评测,重点调优,例如使用performance自己实现下等
个人意见,如有错误,烦请指正,谢谢!

from interview.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.