Skip to content

Instantly share code, notes, and snippets.

@cagataygurturk
Created March 22, 2017 13:42
Show Gist options
  • Save cagataygurturk/be3bbd3a90a9c3bb8fa1facc6aabd761 to your computer and use it in GitHub Desktop.
Save cagataygurturk/be3bbd3a90a9c3bb8fa1facc6aabd761 to your computer and use it in GitHub Desktop.
$(function ($) {
var scanInterval = 2000;
if(typeof window.performance.getEntriesByType === 'undefined') return;
var alreadyLoggedResources = {};
var logHttpResource = function(resourceName) {
if(alreadyLoggedResources.hasOwnProperty(resourceName)) {
return;
}
console.log(resourceName + ' - ' + location.href); // LOG HERE
alreadyLoggedResources[resourceName] = true;
};
var detectHttpResources=function() {
$($.grep(window.performance.getEntriesByType("resource"), function(resource){
return resource.name.startsWith('http://');
})).each(function(i, resource){
logHttpResource(resource.name);
});
window.setTimeout(detectHttpResources, scanInterval);
};
$(document).ready(detectHttpResources);
}(jQuery));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment