How to get list of network requests done by HTML

后端 未结 5 958
情话喂你
情话喂你 2020-11-27 16:46

How can i get the list of network requests using Javascript done by the HTML, as seen in the chrome devtools.

For example:

5条回答
  •  悲&欢浪女
    2020-11-27 17:38

    You could get the URLs of requests to be made when the page loads but retrieving any sort of statistics on load times is unrealistic. Query elements which make these kind of resource requests such as script, link or img.

    For example:

    var urls = Array.prototype.map.call(
        document.querySelectorAll("link, img, script, iframe"), // Elements which request external resources
        function(e) { // Loop over and return their href/src
            return e.href || e.src; 
        }
    );
    

提交回复
热议问题