Skip to content
This repository has been archived by the owner on Jan 4, 2023. It is now read-only.

Commit

Permalink
Create element_count.js (#158)
Browse files Browse the repository at this point in the history
  • Loading branch information
bkardell authored and rviscomi committed Apr 27, 2019
1 parent 12def8a commit 7f62119
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions custom_metrics/element_count.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
return JSON.stringify(
Array.from(
document
.querySelectorAll('*'))
.reduce((acc, el) => {
let tag = el.tagName.toLowerCase()
acc[tag] = (typeof acc[tag] !== 'undefined') ? acc[tag] : 0
acc[tag]++
return acc
}, {}
)
)

0 comments on commit 7f62119

Please sign in to comment.