Page load time with JavaScript

前端 未结 6 2383
梦谈多话
梦谈多话 2020-12-23 17:27

I am looking for a proper way to test the time it takes a page to fully load all its resources. What I\'ve done so far is add:

window.startTime = (new Date).         


        
6条回答
  •  渐次进展
    2020-12-23 17:58

    It is pretty much the only way in legacy browsers to measure times. But for the rescue, most browsers do implement the window.performance object which offers a very, very accurate way of getting times.

    A typical window.performance.timing output:

    connectEnd 1351036536696
    connectStart 1351036536696
    domComplete 1351036538277
    domContentLoadedEventEnd 1351036538146
    domContentLoadedEventStart 1351036538119
    domInteractive 1351036538042
    domLoading 1351036537552
    domainLookupEnd 1351036536694
    domainLookupStart 1351036536694
    fetchStart 1351036536696
    loadEventEnd 1351036538295
    loadEventStart 1351036538277
    navigationStart 1351036536696

    ..which is not even the full list.

提交回复
热议问题