image - Parse pending external resources in javascript at the runtime of a html page? -
question:
how count totalnumber of pending resources being made page in javascript?
getentriesbytype here's quick snippit of page images , http requests:
<div id="results"></div> <img src="http://placekitten.com/g/200/100" alt=""/> //resource 1 <img src="http://placekitten.com/g/240/500" alt=""/> //resource 2 <img src="http://placekitten.com/g/210/300" alt=""/> //resource 3 <img src="http://placekitten.com/g/500/300" alt=""/> //resource 4 <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.0.0-alpha1/jquery.min.js"></script> //resource 5 <script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/3.10.1/lodash.min.js"></script> //resource 6 <script> var results = document.getelementbyid('results'); var r = new xmlhttprequest(); r.open("get", "http://www.filltext.com?rows=10&f={firstname}", true); r.onreadystatechange = function () { if (r.readystate != 4 || r.status != 200) return; var data = json.parse(r.responsetext); (i = 0; < data.length; i++) { results.innerhtml += '<li>' + data[i].f + '</li>' } }; r.send(); //resource 7 var hey = window.performance.getentriesbytype("resource"); console.log(hey); //returns 0 :( hope 7 before dom renders. </script>
+1 @jaromanda.
try this:
settimeout(function(){ var hey = window.performance.getentriesbytype("resource"); console.log(hey); }, 0);
Comments
Post a Comment