Welcome to OGeek Q&A 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 Reply

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...