Reputation: 1274
I am looking into reducing the size of a website's DOM.
When I run Lighthouse over a page the DOM rightly highlighted as excessive is 1,824 elements.
When I then go into the console and run a small script document.getElementsByTagName('*')
it returns HTMLCollection(2212) [HTML, ...]
which is somewhat higher.
I am assuming either
Does anyone have any insight into this?
Upvotes: 1
Views: 621
Reputation: 4415
Google Lighthouse is counting the DOM elements within the <body>
only.
document.getElementsByTagName('*')
returns DOM elements including the <head>
Upvotes: 2