The DOM is the tree of every HTML element on a page: each section, column, button or icon adds a node to it. The bigger it is, the longer the browser takes to compute the layout, apply styles and respond to clicks. PageSpeed Insights flags the problem with the “Avoid an excessive DOM size” warning. On WordPress, it is one of the most frequent warnings, and one of the most poorly handled.
Why DOM size matters for Core Web Vitals
A heavy DOM mostly hurts INP, the responsiveness metric measuring the delay between an interaction and the display of its response. Every click that changes the page forces the browser to recompute part of the tree. It also slows the first render on mobile, where the processor is far less powerful than on a desktop. Lighthouse starts warning at around 800 elements and treats the page as failing beyond about 1,400.
Measure your DOM in ten seconds
Open the page, then the browser developer tools console, and paste this line. It returns the total number of elements:
document.querySelectorAll('*').length
Measure at least the home page, a service page, a post and, for a shop, a category page. Gaps between page templates often show where to look.
What bloats the DOM on WordPress
- Page builders: a section, a column, a container and a widget wrap every text block in four or five levels of divs.
- Content duplicated for mobile and desktop: two versions of the same section, one hidden with CSS, both remain in the DOM.
- Mega menus, which load hundreds of links on every page, even when nobody opens them.
- Sliders and carousels, SVG icons inlined one by one, and long lists of products or comments.
Reduce the DOM without rebuilding the site
Flatten the page builder structure
With Elementor, switch on Flexbox containers instead of the old sections and columns: one container replaces two to three levels of nesting. Remove empty containers used only to create space, a margin does the same job.
Load only one version of each section
Instead of two blocks hidden depending on the screen, build a single section that adapts. It is often the quickest win: on some sites, half the DOM is invisible.
Defer what is not visible
For long pages, the CSS content-visibility property tells the browser not to compute the rendering of off-screen sections until the user gets close. For lists, paginate or load more on demand. For menus, only generate deep submenus when they are opened.
.long-section {
content-visibility: auto;
contain-intrinsic-size: auto 800px;
}
Frequently asked questions
Should page builders be abandoned?
Not necessarily. A page builder used well, with modern containers and no needless nesting, stays under the thresholds. For sites where performance is a business issue, a custom theme built with Gutenberg blocks naturally produces a DOM two to three times lighter.
Does a cache plugin reduce DOM size?
No. A cache speeds up delivering the page, not how the browser processes it. The DOM stays the same, you have to work on the HTML structure.
Author
Walid SadfiWalid Sadfi is the founder of Evolurise, a team of engineers deployed on site with its clients: custom development (WordPress, Drupal, React, Laravel), AI agents, DevOps and team training. With 8 years of experience, he supports SMEs and large companies, from understanding the problem to deploying the solution. On this blog he shares practical, field-tested insights.