How to access performance object of every resource in a web page?

前端 未结 3 1134
-上瘾入骨i
-上瘾入骨i 2021-01-19 00:14

I can see, in Chrome Developer tools, loading time, time it took to get a particular resource from server and other info, for all of the resources in a webp

3条回答
  •  死守一世寂寞
    2021-01-19 00:58

    You should be able to use window.performance.getEntries() to get resource-specific stats:

    var resource = window.performance.getEntries()[0];
    
    console.log(resource.entryType);  // "resource"
    console.log(resource.duration);   // 39.00000000430737
    console.log(resource.startTime);  // 218.0000000007567
    

    Sample from the above link:

    enter image description here

提交回复
热议问题