Created
March 15, 2018 03:07
-
-
Save zswang/9a6b11adca62ee2e4ed7dc5e1e74b13c to your computer and use it in GitHub Desktop.
Get the number of elements in the current page
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
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