UntitledGraphic
UntitledGraphic

Reputation: 1274

Why does Google Lighthouse not count all the DOM elements for its DOM size calculation

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

Answers (1)

Dan Mullin
Dan Mullin

Reputation: 4415

Google Lighthouse is counting the DOM elements within the <body> only.

document.getElementsByTagName('*') returns DOM elements including the <head>

Upvotes: 2

Related Questions