Created
December 8, 2016 20:06
-
-
Save lucamug/ea38bf8ab81115153372e4b4882e0e02 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function() { | |
function getSource(url, callback) { | |
var xhr = new XMLHttpRequest(); | |
xhr.onreadystatechange = function() { | |
if (xhr.readyState === XMLHttpRequest.DONE) { | |
return callback(xhr.responseText); | |
} | |
}; | |
xhr.open('GET', url, true); | |
xhr.send(null); | |
} | |
function countScripts(p) { | |
var count = (p.match(/<script/g) || []).length; | |
return (count); | |
} | |
var url = document.location.href; | |
getSource(url, function(source) { | |
console.log(url + "\n\tScripts in source: " + countScripts(source) + "\n\tScripts in DOM: " + document.getElementsByTagName("script").length); | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment