zoukankan      html  css  js  c++  java
  • 统计网页加载时间

    Web performance APIs

    可以得到各种时间,如dns解析时间,连接时间、跳转时间、加载时间等指标。
    这些API需要在页面加载完成后才能使用,需要在window.onload事件中读取各种数据,因为很多值必须在页面完全加载之后才能得出。

    • 页面加载API

    window.performance.timing 返回一个只读的PerformanceTiming对象,用于分析页面整体性能指标,常用的统计数据如下:

    • DNS查询耗时 :domainLookupEnd - domainLookupStart
    • TCP链接耗时 :connectEnd - connectStart
    • request请求耗时 :responseEnd - responseStart
    • 解析dom树耗时 : domComplete- domInteractive
    • 白屏时间 :responseStart - navigationStart
    • domready时间 :domContentLoadedEventEnd - navigationStart
    • onload时间 :loadEventEnd - navigationStart

    其中navigationStart为准备加载新页面的起始时间,loadEventEnd文档触发load事件结束时间

    • 资源加载API

    window.performance.getEntries() 显示所有静态资源的加载时间
    window.performance.getEntriesByName() 获取相应名字资源的加载时间
    window.performance.getEntriesByType() 获取相应类型资源的加载时间

  • 相关阅读:
    配置日志
    部署项目到jetty
    部署web应用程序到tomcat
    spring boot 整合mybatis
    创建spring boot 项目
    发送http请求
    pom.xml文件中dependency标签的scope子标签
    Ubuntu apparmor何方神圣
    Ubuntu Nginx下配置网站ssl实现https访问
    打造私有的DNS 服务
  • 原文地址:https://www.cnblogs.com/wangxirui/p/13343992.html
Copyright © 2011-2022 走看看