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

前端 未结 3 1104
-上瘾入骨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:48

    window.performance.getEntries() may return not all resources. after bufferful some records is disapear need check it before it happend


    head code part

    var storedEntries = [];
    var updateStoredEntries = p => {
      storedEntries.concat(
        p.getEntries().filter(rec => /yourRegExp/.test(rec.name))
      )
    };
    performance.addEventListener('resourcetimingbufferfull', e => {
      updateStoredEntries(e.target)
    });
    

    ... later part

    updateStoredEntries(performance)
    

提交回复
热议问题