Skip to content

Instantly share code, notes, and snippets.

@zswang
Created March 15, 2018 03:07
Show Gist options
  • Save zswang/9a6b11adca62ee2e4ed7dc5e1e74b13c to your computer and use it in GitHub Desktop.
Save zswang/9a6b11adca62ee2e4ed7dc5e1e74b13c to your computer and use it in GitHub Desktop.
Get the number of elements in the current page
console.log(
[...document.querySelectorAll("*")]
.map(el => el.nodeName)
.sort()
.filter((item, index, arr) => arr[index - 1] !== item).length
);
var s = new Set();
[...document.querySelectorAll("*")].forEach(el => s.add(el.nodeName));
console.log(s.size);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment