Skip to content

Instantly share code, notes, and snippets.

@nolanlawson
Last active June 22, 2022 13:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nolanlawson/07644f13293a3deeb8fcdf0a15a5148b to your computer and use it in GitHub Desktop.
Save nolanlawson/07644f13293a3deeb8fcdf0a15a5148b to your computer and use it in GitHub Desktop.
Measure max DOM depth
Math.max(...[...document.querySelectorAll('*')].map(node => {
let count = 0
while ((node = node.parentNode)) { count++ }
return count
}))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment