开发者社区 问答 正文

首屏、白屏时间如何计算?

首屏、白屏时间如何计算?

展开
收起
kun坤 2019-11-28 16:09:07 609 分享 版权
1 条回答
写回答
取消 提交回答
  • 答案:

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

    performance.timing.responseStart - performance.timing.navigationStart
    
    首屏时间
    
    window.onload = () => {
        new Date() - performance.timing.responseStart
    }
    
    
    2019-11-28 16:09:22
    赞同 展开评论
问答地址: