You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
window.addEventListener('load',(event)=>{// Time to Interactive 可交互时间lettiming=performance.getEntriesByType('navigation')[0];console.log(timing.domInteractive);console.log(timing.fetchStart);letdiff=timing.domInteractive-timing.fetchStart;console.log("TTI: "+diff);})
letvEvent='visibilitychange';if(document.webkitHidden!=undefined){// webkit 事件名称vEvent='webkitvisibilitychange';}functionvisibilityChanged(){if(document.hidden||document.webkitHidden){console.log("Web page is hidden.")}else{console.log("Web page is visible.")}}document.addEventListener(vEvent,visibilityChanged,false);
用户网络状态监听
constconnection=navigator.connection||navigator.mozConnection||navigator.webkitConnection;lettype=connection.effectiveType;functionupdateConnectionStatus(){console.log("Connection type changed from "+type+" to "+connection.effectiveType);type=connection.effectiveType;}connection.addEventListener('change',updateConnectionStatus);
The text was updated successfully, but these errors were encountered:
常用性能指标计算
domainLookupEnd - domainLookupStart
connectEnd - connectStart
connectEnd - secureConnectionStart
responseStart - requestStart
responseEnd - responseStart
domInteractive - responseEnd
loadEventStart - domContentLoadedEventEnd
responseStart - domainLookupStart
responseEnd - fetchStart
domInteractive - fetchStart
domContentLoadEventEnd - fetchStart
loadEventStart - fetchStart
transferSize - encodedBodySize
performance.navigation.redirectCount
redirectEnd - redirectStart
性能APIs实例
The text was updated successfully, but these errors were encountered: