当前位置:网站首页>白屏时间、首屏时间
白屏时间、首屏时间
2022-06-11 10:29:00 【前端同学】
白屏时间
浏览器显示第一个字符或者元素的时间
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>白屏</title>
<script type="text/javascript">
// 不兼容performance.timing 的浏览器,如IE8
window.pageStartTime = Date.now();
</script>
<!-- 页面 CSS 资源 -->
<link rel="stylesheet" href="common.css">
<link rel="stylesheet" href="page.css">
<script type="text/javascript">
// 白屏时间结束点
window.firstPaint = Date.now();
</script>
</head>
<body>
<!-- 页面内容 -->
</body>
</html>
可使用 Performance API 时
白屏时间 = firstPaint - performance.timing.navigationStart;
可使用 Performance API 时
白屏时间 = firstPaint - pageStartTime;
首屏时间
首屏时间是指用户打开网站开始,到浏览器首屏内容渲染完成的时间,dom处于比较稳定的阶段。
对于用户体验来说,首屏时间是用户对一个网站的重要体验因素。通常一个网站,如果首屏时间在5秒以内是比较优秀的,10秒以内是可以接受的,10秒以上就不可容忍了。超过10秒的首屏时间用户会选择刷新页面或立刻离开。
在 SSR(服务端渲染)的应用中,我们认为html的body渲染完成的时间就是首屏时间。我们通常使用 W3C 标准的Performance对象来计算首屏时间。
Performance经常被用于采集性能数据,因为对象内置了几乎所有常用前端需要的性能参数。
但是随着 Vue和React等前端框盛行, 导致Performance无法准确的监控到页面的首屏时间。因为页面的body是空,浏览器需要先加载js, 然后再通过js来渲染页面内容。那我们使用什么数据来当做首屏时间呢?
总结为一句话,就是SSR使用Dom渲染结束的时间,SPA的项目使用FMP的时间。
边栏推荐
- minIni移植到littlefs
- Dynamically render data and carousels
- 1. system in Library
- Ngui, floating blood
- Correct opening method of RPC | understand go native net/rpc package
- No more! The entry byte beat for a week and ran decisively.
- Differences between beanfactory and factorybean
- 【CV基础】颜色:RGB/HSV/Lab
- NGUI,背包拖拽,以及随机克隆图片知识点
- NGUI,地图放大缩小
猜你喜欢

Reprint: linearlayout+fragment to achieve the lower navigation bar effect

MySQL基础篇常用约束总结上篇

rpc的正确打开方式|读懂Go原生net/rpc包

Arbitrum infrastructure: a quick start

金仓数据库KingbaseES中的PL/SQL 编译检查

Cadence OrCAD capture design method to avoid misoperation graphic tutorial

MySQL基础篇常用约束总结下篇

With determination to forge ahead, JASMINER continues to deepen its brand strength

金仓数据库KingbaseES中的sys_checksums坏块检测功能

用真金做的电路板——金手指
随机推荐
Database design and paradigm explanation
金仓数据库KingbaseES中的PL/SQL 编译检查
[torch]: parallel training and can dynamically set the batch size of the first GPU
NGUI,地图放大缩小
Jedislock redis distributed lock implementation
What is the SOA or ASO of MOSFET?
No more! The entry byte beat for a week and ran decisively.
Cadence OrCAD capture design method to avoid misoperation graphic tutorial
rpc的正确打开方式|读懂Go原生net/rpc包
iPhone 15 被迫用上 Type-C 接口
Introduction to steamvr
Ugui mouse click diffusion UI effect
NGUI,背包拖拽,以及随机克隆图片知识点
Record yesterday's embarrassment
電子設備輻射EMC整改案例
安装MySQL ,出现由于找不到 MSVCR120.dll,无法继续执行代码解决方法”
修复UICollectionView 没有到达底部安全区的问题
Use of JMeter (simulating high concurrency)
C#入門系列(十一) -- 多維數組
Address of my bookmark