Skip to content

Instantly share code, notes, and snippets.

@MattSandy
Last active August 14, 2019 16:16
Show Gist options
  • Save MattSandy/15ec1155a2ee439c446acf00a5fa8e50 to your computer and use it in GitHub Desktop.
Save MattSandy/15ec1155a2ee439c446acf00a5fa8e50 to your computer and use it in GitHub Desktop.
Get character length of every document on the page
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