Are There Any Stats About DOM Sizes in Modern Pages?

#1

Question on r/webdev on reddit:

I would like to have some grasp on how many dom elements (nodes) are normally found in modern web pages. Of course, I don’t mean exact, just in what size orders are we talking nowadays. I don’t even know what is normal page anyways, and dynamic nature of web today (we can add/remove nodes with JS at runtime) makes it impossible to count such stats precisely. Anyway, I would like to give it a shot and ask if there are some stats about what is normally found these days. Like are we talking about size order of hundreds of elements in today’s DOM trees, or thousands, or tens of thousands? I have read some blog post where sizes around 5K ~ 20K seems to appear (somebody mentioned in comments), but that was nothing really confirmed nor were there any references to follow.

Yeah, I am aware it’s a long shot, but anyway, if there are any good stats I would really like to see them. I wasn’t able to find something myself.

The summary_pages dataset includes a numDomElements field that answers this question directly. Here’s a query that analyzes the 10, 50, and 90th percentiles over time for both desktop and mobile:

SELECT
  REPLACE(SUBSTR(_TABLE_SUFFIX, 0, 10), '_', '-') AS date,
  IF(ENDS_WITH(_TABLE_SUFFIX, 'desktop'), 'desktop', 'mobile') AS client,
  APPROX_QUANTILES(numDomElements, 1000)[OFFSET(100)] AS p10_dom_size,
  APPROX_QUANTILES(numDomElements, 1000)[OFFSET(500)] AS median_dom_size,
  APPROX_QUANTILES(numDomElements, 1000)[OFFSET(900)] AS p90_dom_size
FROM
  `httparchive.summary_pages.*`
GROUP BY
  date,
  client
ORDER BY
  date,
  client

Here’s a sheet with the raw results

A little surprised that mobile DOM size wasn’t available until 2016 but here we are. The distribution hasn’t actually changed too much over the years.

If you just want a simple query to get the latest median DOM size:

SELECT
  APPROX_QUANTILES(numDomElements, 1000)[OFFSET(500)] AS median_dom_size
FROM
  `httparchive.latest.summary_pages_desktop`

It’s about 600 elements.

#2

Prior to 2016, mobile testing was done on physical iOS devices running an agent with limited capabilities compared to the main desktop agent. In 2016 we switched it over to emulation so it could scale up which also opened up the full capabilities.

1 Like