Using jQuery I can get easily the number of DOM elemetns used by a web page:
$(\'*\').length;
But not all web sites are using jQuery.
Using a recursive function countChildrenNumber
:
function countChildrenNumber(el) {
let result = 0
if (el.children && el.children.length > 0) {
result = result + el.children.length
for (let i = 0; i < el.children.length; i++) {
result = result + countChildrenNumber(el.children[i])
}
}
return result
}
then call it by passing document
as the parameter
countChildrenNumber(document)