Performance

Reducing DOM Size on Page Builder Sites Without Rebuilding Everything

Reducing DOM Size on Page Builder Sites Without Rebuilding Everything

If you run a WordPress site built with a page builder, there’s a good chance Lighthouse has warned you to “avoid an excessive DOM size”. It’s one of the most common audit warnings on Elementor, Divi, WPBakery and similar sites, and also one of the most commonly ignored, because it’s not obvious what to do about it. The page looks fine. Why does the number of HTML elements matter? The practical answer is to reduce DOM size section by section.

It matters because every element in the page has a cost. The browser must parse it, calculate its styles, work out its position and paint it, and it must repeat some of that work every time something changes. Large DOMs make pages slower to render, slower to respond to taps and heavier on memory, and the effect is much stronger on mid-range phones. Learning to reduce DOM size is one of the most effective ways to improve interaction responsiveness on builder sites, and it can usually be done section by section without rebuilding the whole site.

What counts as a large DOM

The DOM, or Document Object Model, is the browser’s tree of every element on the page. Lighthouse flags pages when:

  • The total number of elements exceeds about 1,400
  • The tree is more than 32 levels deep
  • Any single element has more than 60 direct children

A typical hand-coded article page might have 500 to 900 elements. Page builder pages commonly have 2,000 to 5,000, and I’ve seen homepages with more than 10,000.

Why builders produce so many elements

Page builders need to be flexible. Every section, column and widget can be styled, positioned, animated and made responsive independently. To make that possible, builders wrap content in several layers of containers. A single heading in some builders sits inside a section, a container, a column, a column wrapper, a widget wrapper and a widget container before you reach the h2 itself.

Multiply that by every heading, button, image and icon on a page and the count climbs fast. Common contributors:

  • Deeply nested sections, columns and inner sections
  • Icon lists and feature boxes where each item has several wrappers
  • Separate mobile and desktop versions of the same content, with one hidden by CSS
  • Mega menus with hundreds of links rendered on every page
  • Sliders and carousels with many slides, all present in the HTML
  • Footer widgets with long link lists
  • Inline SVG icons repeated many times
  • Social share buttons and other repeated components

Step 1: Measure where the elements are

Start by finding which parts of the page are heaviest. In the browser console, you can count elements:

To find which sections contribute most, run a quick snippet that counts descendants of each top-level section:

Adjust the selectors for your builder. The output shows which sections hold the most elements. Very often, three or four sections account for more than half the total.

Lighthouse also shows the element with the most children and the deepest element, which point to specific problems.

Step 2: Remove duplicated mobile and desktop content

This is often the biggest win. To achieve a different layout on mobile, builders make it easy to create a section, duplicate it, style one copy for desktop and one for mobile, and hide each on the other device. Both copies remain in the HTML on every device. The browser still parses both, and some builders still load images in the hidden copy.

Instead, use one section with responsive settings: different column widths, order, spacing and font sizes per breakpoint. Modern builders, especially those with flexbox containers, can achieve most mobile layouts from a single structure. Reserve separate versions for cases where the content truly differs.

Step 3: Flatten nested structures

Older builder layouts often nest sections inside sections inside columns to achieve alignment. Newer container-based systems, such as Elementor’s flexbox containers, Divi 5’s flexbox layout and similar features in other builders, can achieve the same layouts with far fewer wrappers.

Where a section has inner sections purely for spacing or alignment, rebuild it with a single container using gap and alignment settings. Elementor provides a converter for legacy sections, though the result often needs tidying.

Also check builder settings for optimised markup options. Elementor, for example, has had an “Optimized DOM Output” experiment and later made leaner markup the default, removing some wrapper elements. Make sure such options are enabled on older sites.

Step 4: Simplify the mega menu and footer

Navigation and footers appear on every page, so their size is multiplied across the site. A mega menu with 200 links, icons and images can add hundreds or thousands of elements to every single page, even though most visitors never open it.

Options:

  • Reduce the number of links. Analytics usually show most mega menu links are rarely used.
  • Load mega menu content on demand, only when the menu is opened, if your menu plugin supports it.
  • Use one menu structure for mobile and desktop rather than two separate menus.
  • Trim footer link lists to the essentials.

Step 5: Tame sliders, carousels and tabs

A testimonial carousel with 30 slides puts all 30 into the DOM, each with its own wrappers, images and text. Many visitors see only the first two or three.

Reduce the number of slides, or replace the carousel with a static grid of the best three or four testimonials. For tabs and accordions with heavy content, consider whether all of it needs to be on the page, or whether some belongs on its own page.

Step 6: Replace repeated inline SVGs

Icon lists, feature boxes and buttons often use inline SVG icons. Each inline SVG can contain several elements: paths, groups and shapes. Repeated dozens of times, they add up. Using an SVG sprite with use references, an icon font, or simply fewer icons reduces the count. Some builders let you choose how icons are output, and inline SVG is not always the lightest option.

Step 7: Question every widget

Look at the heaviest sections and ask whether each widget earns its place. Decorative dividers made of several elements, animated counters, social feeds embedded in full, background video wrappers and multiple nested buttons can often be simplified or removed without changing how the page reads.

Often a section built with eight widgets can be rebuilt with two: a heading and a rich text block with a button. Visually almost identical, structurally much lighter.

Step 8: Use native blocks for content-heavy pages

For blog posts, documentation and long articles, the block editor produces much leaner markup than most builders. Many sites use a builder for the homepage and landing pages, and the block editor for everything else. That keeps the builder’s flexibility where it adds value and leaves the majority of pages lightweight.

Measuring the impact

Count elements before and after each change, and measure the effect on real performance metrics:

  • Total Blocking Time and Interaction to Next Paint in lab tests with CPU throttling
  • Style recalculation and layout times in the Chrome DevTools Performance panel
  • Field INP over the following weeks

Reducing a homepage from 5,000 to 2,000 elements typically produces a noticeable improvement in responsiveness on mid-range phones, even when nothing else changes. It also tends to make pages easier to maintain, because simpler structures are easier to edit.

When rebuilding is the right answer

Sometimes a page is so heavily nested and duplicated that optimising it costs more than rebuilding. That’s often true of homepages built years ago with legacy sections and many workarounds. If a page has more than 5,000 elements, separate mobile and desktop versions throughout and multiple nested inner sections, rebuilding it with modern containers or blocks may be faster than untangling it.

The good news is that you can do it one page at a time, starting with the pages that get the most mobile traffic. Every page you simplify helps you reduce DOM size across the site and makes the next one easier.

Preventing DOM bloat on new pages

Once you’ve cleaned up the worst pages, keep new ones lean. A few habits help builders and content editors alike: start from saved templates that already use flat container structures, avoid duplicating sections for mobile, use global widgets or synced patterns for repeated elements rather than rebuilding them, and check the element count before publishing an important new landing page. Some teams set a soft budget, such as 1,500 elements for landing pages, and treat anything above it as a reason to simplify.

Frequently asked questions

Does DOM size affect SEO directly?

Not as a ranking factor on its own. It affects performance metrics like INP and the overall user experience, which matter.

Is 1,400 elements a hard limit?

No. It’s a warning threshold. Pages slightly above it are fine. The concern is pages with several thousand elements.

Do lazy-loaded sections reduce DOM size?

Only if the content isn’t in the HTML until it’s needed. Lazy-loading images reduces downloads but doesn’t remove elements from the DOM.

Will switching builders fix DOM size?

Some builders and versions produce leaner markup than others, but how a page is built matters as much as which builder is used.