Last active
August 14, 2019 16:16
-
-
Save MattSandy/15ec1155a2ee439c446acf00a5fa8e50 to your computer and use it in GitHub Desktop.
Get character length of every document on the page
This file contains hidden or 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
var all = document.getElementsByTagName("*"); | |
var tags = []; | |
var tmp = 0; | |
for (var i=0, max=all.length; i < max; i++) { | |
tmp = 0; | |
jQuery.each(all[i].attributes,function(pos,element){ | |
tmp = tmp + element.name.length + element.value.length; | |
}); | |
tmp = tmp + jQuery(all[i]).html().length; | |
if(typeof(tags[jQuery(all[i]).prop("tagName")]) == "undefined") { | |
tags[jQuery(all[i]).prop("tagName")] = tmp; | |
} else { | |
tags[jQuery(all[i]).prop("tagName")] = tags[jQuery(all[i]).prop("tagName")] + tmp; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment