当前位置:网站首页>SPA首屏加载优化
SPA首屏加载优化
2022-04-22 10:17:00 【思ۣۖิิۣۖิ**空**】
首屏加载
就是从输入网址址,到所有资源渲染到页面,首屏加载可以说是用户体验中最重要的环节,由于单页面应用,资源体积过大,首次进行全部加载耗时,导致白屏
加载过慢
在页面渲染的过程,导致加载速度慢的因素可能如下:
- 网络延时问题
- 资源文件体积是否过大
- 资源是否重复发送请求去加载了
- 加载脚本的时候,渲染内容堵塞了
解决方法
减小入口文件体积
比如路由懒加载和异步组件,配置路由时采用动态加载路由形式
{
path: '/404',
component: () => import('@/views/404'),
},
静态资源本地缓存
采用强制缓存和协商缓存,设置Cache-Control, Last-Modified, Etag字段
合理利用localStorage
UI框架按需加载
例如使用element-ui框架时, 使用组件不要全部将整个框架导入,应该按需导入
全部导入:
import ElementUI from 'element-ui'
Vue.use(ElementUI)
按需导入:
import { Button, Input } from 'element-ui';
Vue.use(Button)
Vue.use(Input)
图片资源的压缩
将小图片base64化,或者使用在线字体图标、雪碧图减少服务器压力
使用SSR
SSR(Server side ),也就是服务端渲染,组件或页面通过服务器生成html字符串,再发送到浏览器
从头搭建一个服务端渲染是很复杂的, Vue应用建议使用Nuxt.js实现服务端渲染
版权声明
本文为[思ۣۖิิۣۖิ**空**]所创,转载请带上原文链接,感谢
https://blog.csdn.net/qq_45228255/article/details/124334607
边栏推荐
- Error message during unity3d build: missing project ID in unity solution
- Summary of time function in Oracle
- OGG-00663 OCI Error ORA-02396: exceeded maximum idle time
- 分表和分区的区别
- [age appropriate friends of interesting programming questions] (detailed explanation of the original title of leetcode)
- JWT源码浅析(四层封装,有示意图)
- HAS2022 | 第19届华为全球分析师大会即将启幕!
- SQL syntax
- UVC camera 封装类
- TIANTI 22 analog l3-2 puzzle a punch in reward (30 points)
猜你喜欢

Command ‘yum‘ not found, but can be installed with: apt install yum

头条面试居然跟我扯了半小时的Semaphore

基于SSM的电影在线购票系统

Dext diagnostic database supporting AUTOSAR classic and adaptive platform
![[QT notes] use qpainter to draw various basic graphics](/img/7a/78e96d8689582d145586a4da3d3bb0.png)
[QT notes] use qpainter to draw various basic graphics

Linux Installation Oracle 19C Full Version (graphics + silent installation)

Linux 7 silent installation of Oracle 11g

Laya Uncaught ReferenceError: spine is not defined

美团一面:有在⼯作时间中使⽤过 jstat, jmap, mat⼯具吗? 能给⼀个实际的例⼦说明⼀下吗?

Nacos
随机推荐
最通俗易懂的依赖注入之生命周期
build perl from source
oracle19.3升级到19.6
Windows下oracle11.2.0.1升级至oracle11.2.0.4
Oracle 11.0 under Windows Upgrade from 2.0.1 to Oracle 11.0 2.0.4
The VirtualBox virtual machine uses virtio net to run dpdk + VPP and cannot receive VLAN messages
Simple operation of QT axobject Library
MySQL multi instance installation method I
P8 data broadcasting
dataguard (ADG)备库移动(迁移)数据文件
通过LayerDrawable实现进度条的功能
Cross platform compilation
DA14580BLE点亮LED
企业级 Web 开发的挑战
adroid SQLiteOpenHelper数据表结构升级
Golang time strings common methods
Share some unknown and super easy-to-use API functions in sklearn module
最通俗易懂的依赖注入之服务容器与作用域
docker 启动mysql问题,You need to specify one of MYSQL_ROOT_PASSWORD, MYSQL_ALLOW_EMPTY_PASSWORD and MYSQ
天梯22模拟 L3-2 拼题A打卡奖励 (30 分)