Possible to list external resources loaded on a webpage with JavaScript?

后端 未结 1 1891
感动是毒
感动是毒 2021-01-02 01:01

I\'d like to have an interval that keeps track of what items are being loaded on the current page. For example, let\'s say I have a page that loads a css file, a few scripts

相关标签:
1条回答
  • 2021-01-02 01:55

    You can possibly use Resource Timing to retrieve resource names:

    var resources = window.performance.getEntriesByType("resource");
    resources.forEach(function (resource) {
        console.log(resource.name);
    });
    

    It's an extension of Navigation Timing (Can I use...) and is supported in many browsers.

    0 讨论(0)
提交回复
热议问题