Skip to content

Instantly share code, notes, and snippets.

@nolanlawson
Created May 10, 2021 04:04
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/ac589bbe512c3efa9306574ce62a06a5 to your computer and use it in GitHub Desktop.
Save nolanlawson/ac589bbe512c3efa9306574ce62a06a5 to your computer and use it in GitHub Desktop.
Count stats on a web page
({
numNodes: $$('*').length,
numCustomElements: $$('*').filter(_ => customElements.get(_.tagName.toLowerCase())).length,
numUniqueCustomElements: [...new Set([...$$('*').map(_ => _.tagName.toLowerCase())])].filter(_ => customElements.get(_)).length,
numRulesWithoutCrossOrigin: [...document.styleSheets].map(_ => { try { return _.cssRules.length } catch (e) { return 0 }}).reduce((a, b) => a + b, 0)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment