Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
3.7k views
in Technique[技术] by (71.8m points)

前端怎么统计白屏时间,包括后端处理的时间?

前端目前能统计到的白屏时间,只能是从Html下载下来才能开始统计
白屏时间 = endTime - startTime

<html>
 <head> 
  <script>            var startTime = new Date()                </script> 
  <title>白屏时间</title> 
  <link href="xxxxx" /> 
  <link href="xxxxx" /> 
  <script>            var endTime = new Date()                </script> 
 </head> 
 <body>
  xxxxxx
 </body>
</html>

真实用户的白屏时间应该是:
白屏时间= endTime- 用户打开url的时间点(如果是传统的服务端渲染页面,这个返回的时间无法统计在前端的白屏时间内)

<html>
 <head> 
  <title>白屏时间</title> 
  <link href="xxxxx" /> 
  <link href="xxxxx" /> 
  <script>            var endTime = new Date()                </script> 
 </head> 
 <body>
  xxxxxx
 </body>
</html>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
performance.timing.domContentLoadedEventEnd - performance.timing.fetchStart;

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...