Optimize DOM size
The Optimize DOM size insight detects if a web page has an excessively large Document Object Model (DOM), and reports the total DOM elements for a page, the page's maximum DOM depth, and the element with the most child elements.

A large DOM can increase the duration of style calculations and layout reflows, impacting page responsiveness. A large DOM will also increase memory usage. Learn how to avoid an excessive DOM size.
Understanding Optimize DOM size
When a web page is loaded, the browser creates a DOM of the page. The DOM represents the structure of a web page's HTML as a tree of branches and nodes, and provides JavaScript and CSS access to a page's structure and contents.
The larger the DOM, the greater the impact on a browser's ability to render a page quickly and efficiently. Large DOM size also increases a memory usage, and it can affect a page's Interaction to Next Paint (INP) metric.
Every time you add an image, a paragraph, a link, a module/widget from your page builder etc, you're adding more elements (nodes) to the DOM and increasing its size.
The distance between each node and the root element is known as the depth, and all the elements below each (parent) node are called child nodes.
How to improve DOM size
This insight is not something that can be completely resolved by using caching plugins. The issue is specific to the architecture of your site, and you will need to adopt different strategies to reduce DOM size.
You could try to:
- Reduce the number of elements
- Avoid excessive DOM manipulation with JavaScript
- Simplify the HTML to reduce DOM depth by removing unnecessary nesting
- Automatic Lazy Rendering is automatically enabled in the WP Rocket
- Reduce the Scope and Complexity of Style Calculations
Basically, reduce the amount of content displayed on each page, and simplify the HTML and CSS.