查看页面首屏时间、白屏时间

Performance 接口可以获取到当前页面中与性能相关的信息。
该类型的对象可以通过调用只读属性 Window.performance 来获得。
白屏时间:

var a = performance.timing.responseStart - performance.timing.navigationStart
console.log(a);  //白屏时间

首屏时间

window.onload = () => {
  var b = new Date() - performance.timing.responseStart
  console.log(b);  //首屏时间
}
posted @ 2020-09-22 09:11  爱代码三千  阅读(755)  评论(0编辑  收藏  举报