Avoiding an excessive DOM size in WordPress is partially making a good theme choice. Consider research into websites that uses the theme, before installing it on your website. Test those websites on Pagespeed and verify their performance.
If you already have a bad-performing website, consider the following for improving or fixing excessive DOM size warnings on Pagespeed.
Lazyload videos, and iframes
Lazyload iframes and videos to reduce dom size. Consider the following plugins:
Lazyload by Wp Media – Lazyload videos and iframes: Free
FlyingPress – Lazyload elements(Including comments section): $60/y
Lazyload images won't reduce DOM size.
Consider fewer page elements, change the theme
Use WordPress reusable blocks to build using fewer classes. Consider the following post to choose a fast theme:
Consider asking the developer to remove unwanted code
If you bought a theme, ask the theme developer to remove unwanted code, and make a custom version for your specifications. Unwanted code can add size to the DOM. Consider the following unwanted functions:
- Remove support for older browsers, if don’t want older browser support.
- Any other function you’re not using but it’s adding classes and code to your DOM.
Update to the latest version of your page builder
Page builders are the most flagged with large dom size by Pagespeed, consider applying all improvements necessary to improve your website DOM structure, if you’re using a page builder.
Stuck on Core Web Vitals?
Get your site optimized today