The short fix
- Count the elements: paste
document.querySelectorAll('*').lengthinto the browser console on the live page. - Find the biggest parts: menus, product grids, sliders, footers and hidden phone or desktop copies.
- Rebuild heavy page-builder sections with fewer wrappers, for example Elementor containers instead of sections and columns.
- Show fewer products, slides and menu items at once, and build filter panels and drawers only when they are opened.
- Re-test and compare the element count and Total Blocking Time.
What PageSpeed Insights is telling you
In PageSpeed Insights this is the Optimize DOM size insight under Insights. Before Lighthouse 13 it was the diagnostic Avoid an excessive DOM size. It reports three numbers: Total elements, DOM depth (the deepest nesting) and Most children (the element with the most direct children, often a menu or a product list).
The rule has changed. The old audit warned at about 800 nodes in the page body and failed at about 1,400. The Lighthouse 13 insight fails only when the page has a large layout or style recalculation that takes more than 40 ms; a large layout touches over 100 layout objects, a large style recalculation over 300 elements. So a page with thousands of elements can pass in PageSpeed Insights and still react slowly once people use it.
In a FlashMax report the card is The page is built from too many parts. It appears when the page has more than 1,500 HTML elements.
Why it slows the page
Each element is something the browser has to style, place and sometimes repaint. A large DOM makes style calculations and layout take longer and uses more memory, and web.dev notes that it affects responsiveness more than most people expect. The cost shows up twice:
- While the page loads, as style, layout and rendering time in Minimize main-thread work. That feeds Total Blocking Time, which carries 30% of the Lighthouse score.
- After it loads, every tap that changes the page (opening a menu, adding to cart, ticking a filter) makes the browser recalculate styles across the whole tree. That shows in Interaction to Next Paint (INP), the Core Web Vital for responsiveness.
Chrome's documentation adds that a deep tree isn't a problem on its own, but it is a sign of unnecessary nesting, a pattern page builders often produce.
How common it is
In our study of 40,951 WooCommerce store home pages (Lighthouse 13, phone settings), 21.1% of stores (8,624) had more than 1,500 elements. Their median phone score was 44, against 54 for stores under the limit. That gap is a correlation, not proof: big pages usually carry more pictures and scripts too. Method and caveats are in the WooCommerce speed study.
How to find what makes the page big
- Run a free test. The FlashMax speed test tells you in about a minute whether the page is over the 1,500-element limit, alongside the other problems on the page.
- Read the insight in PageSpeed Insights. Most children and DOM depth each name an element. They often point straight at a mega menu, a product grid or a page-builder section. If the insight fails, Chrome's Performance panel highlights the slow layout and style events in the flame chart.
- Count it yourself. Open the page, open DevTools (F12, or Cmd+Option+I on a Mac), go to the Console tab and paste the snippet below.
console.log('all', document.querySelectorAll('*').length);
for (const sel of ['header', 'nav', 'main', 'footer', 'ul.products']) {
const el = document.querySelector(sel);
if (el) console.log(sel, el.querySelectorAll('*').length);
}
The first line counts every element on the page as it is now, after scripts have run, so it can differ a little from a test report. The loop counts the elements inside the first header, menu, main area, footer and WooCommerce product list. Run it at phone width too: some themes build a separate mobile menu.
How to fix it on WordPress and WooCommerce
Page builders: fewer wrappers
Builders wrap every widget in layers of divs. In Elementor, the old section, column and inner-section layout adds more of them than Flexbox containers do; Elementor's own help pages say containers improve speed by using fewer dividers. Containers are on by default for new sites and can be activated on existing ones. Also:
- Keep Elementor updated. The wrapper removals from its former Optimized DOM Output feature have been part of Elementor's core since version 3.19.
- Open the Structure window and remove containers that only add spacing; padding and gap settings do the same job without an extra layer.
- Converting a section to a container can't be undone, so duplicate the page or take a backup first.
In Divi, a section holds rows, a row holds columns and modules sit in the columns. In Divi 5 a row can also arrange its columns and modules as a Flexbox or CSS Grid layout, which can replace extra nested rows used only to place things side by side.
One version of each block, not two
Elementor's Hide On Desktop, Hide On Tablet and Hide On Mobile switches (Advanced tab, Responsive section; in the Elementor 4 editor, Display set to None for that device) hide an element on that screen size, but the element stays in the HTML and still counts. A section built twice, once for phones and once for computers, doubles its elements. Build one responsive section and change its layout per device instead.
Menus
Mega menus with every category, sub-category and brand can hold hundreds of links, and many themes print a second copy for the mobile menu. Shopify's theme guide says navigation with 500 to 2,000 DOM nodes is common in themes with duplicate menus. Keep the main menu to the top categories, let category pages carry the deeper links, and prefer a theme or menu plugin that uses one menu for every screen size.
Product grids, sliders and footers
- Every product card is many elements: image, title, price, rating, badges, swatches, buttons. Show fewer at once: in classic themes go to Appearance > Customize > WooCommerce > Product Catalog and lower Products per Row or Rows per Page. If your theme or builder has its own product grid, the setting lives in that widget or block.
- Footers with full category lists, tag clouds and several widget areas add elements to every page. Trim them.
Panels nobody has opened yet
Filter sidebars, cart drawers, quick-view windows and pop-ups are often in the HTML from the start, just hidden. Shopify's guide gives an example of filter facets adding 3,000 to 3,500 nodes to a collection page. If your theme or filter plugin has an option to load a panel only when it is opened, use it.
Shopify and hand-built sites
Shopify. Shopify's theme guide recommends two fixes that match this card: merge duplicate mobile and desktop menus into one menu styled with CSS media queries, and build hidden components such as filter panels, cart drawers and dialogs only when the shopper first opens them.
Hand-built sites. Flatten wrapper-inside-wrapper markup with CSS Grid or Flexbox. Keep content that only appears after a click in a <template> element: its contents are not part of the live DOM until you insert them.
<button id="filters-btn" type="button">Filters</button>
<div id="filters" hidden></div>
<template id="filters-tpl">
<!-- the full filter panel markup -->
</template>
<script>
document.getElementById('filters-btn').addEventListener('click', function () {
var box = document.getElementById('filters');
if (!box.children.length) {
box.appendChild(document.getElementById('filters-tpl').content.cloneNode(true));
}
box.hidden = !box.hidden;
});
</script>
On long pages, content-visibility: auto on sections below the first screen lets the browser skip rendering them until they come near the viewport. It saves rendering work but doesn't lower the element count.
Mistakes to avoid
- Hiding instead of removing. CSS that hides an element on phones leaves it in the page.
- Converting a whole site to containers in one go. The conversion can't be undone, and custom CSS that targets old wrapper classes may stop working. Convert page by page, with a backup.
- Cutting what shoppers use. Removing filters, size swatches or category links to hit a number trades a better score for a worse shop. Load them later instead of deleting them.
- Trading elements for JavaScript. A menu redrawn by a heavy script after load can cost more main-thread time than the elements it saved. Re-test both numbers.
- Expecting lazy loading to help.
loading="lazy"delays image downloads, not elements: a lazy image is still an<img>in the DOM.
How to check the fix worked
- Clear the cache, run the console count again, then re-test with FlashMax or PageSpeed Insights two or three times. Element counts are usually steadier than timings, which vary from run to run.
- Look at the Optimize DOM size numbers and at Total Blocking Time, not only at the score.
- Tap through the page on a phone: menu, filters, variation picker, add to cart. Each should respond at once.
- INP from real visitors, in PageSpeed Insights and in Search Console's Core Web Vitals report, covers the last 28 days, so allow about four weeks.
Questions people ask
How many DOM elements is too many?
Lighthouse no longer uses a single number: the Lighthouse 13 insight fails only when a big style or layout update takes over 40 ms. The older audit warned at about 800 nodes and failed at about 1,400. Our speed test flags pages over 1,500 elements, and most stores in our study (all but 21.1%) stayed under that.
Is DOM size the same as page size?
No. Page size is how many bytes download; DOM size is how many HTML elements the browser builds. A light page can still have a big DOM, for example thousands of menu links, and the fixes are different.
Does hiding elements on mobile reduce DOM size?
No. Hiding with CSS, including page-builder “hide on mobile” switches, leaves the element in the HTML. To lower the count, remove the duplicate or build it only when it is needed.
Will a caching plugin fix an excessive DOM size?
No. Caching makes the server send the HTML faster, but the browser still has to build and style every element. The fix is in the page itself: fewer wrappers, fewer items at once, no duplicates.
Sources
- Optimize DOM size (Chrome for Developers, performance insights)
- Avoid an excessive DOM size (Chrome for Developers)
- How large DOM sizes affect interactivity, and what you can do about it (web.dev)
- Compare grid containers and sections/columns (Elementor Help Center)
- Optimized DOM Output and custom code (Elementor Help Center)
- Show or Hide Columns Per Device (Elementor Help Center)
- The Row in Divi 5 (Elegant Themes Help Center)
- Product Catalog (WooCommerce documentation)
- Merge duplicate mobile and desktop menus into one (Shopify)
- Build DOM for hidden components only when opened (Shopify)
Rather have it done?
The FlashMax team fixes the issues in your report, on a copy first, and shows the before-and-after.
See the speed optimization service