Skip to content

Instantly share code, notes, and snippets.

@pixyj
Created June 14, 2013 09:15
Show Gist options
  • Save pixyj/5780563 to your computer and use it in GitHub Desktop.
Save pixyj/5780563 to your computer and use it in GitHub Desktop.
Calculate total number of nodes in your web page.
var countNodes = function() {
var total = 1;
var count = function(node) {
var i, l;
l = node.children.length;
total += l;
for(i=0; i<l; i++) {
count(node.children[i])
}
}
count(document.body);
return total;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment