Explore the World's Best Ideas
Join today and uncover 100+ curated journeys from 50+ topics. Unlock access to our mobile app with extensive features.
Lighthouse warns us about large DOM sizes because they increase memory usage and can produce expensive style calculations . This can have a significant impact on user experience, especially for users on lower-end devices.
When we work with a tree data structure like the DOM, its depth has a lot to do with how fast operations such as lookups perform on them.
The deeper a tree goes, the more operations it could take to access one of its elements.
5
8 reads
A tree's height and balance impact efficiency and performance, as seen with Binary Search Trees. Consider self-balancing BSTs to maintain a minimum height and fast operations.
Deep DOM trees in CSS can be problematic. Large and nested trees result in expensive style recalculations, affecting performance and responsiveness.
🌳🌳🌳🌳
5
6 reads
You can measure DOM size and depth on your site using a tool like Lighthouse or PageSpeed Insights . If you want to quickly check how many elements you have on the page at any given time, you can run this on your browser’s console:
The main thing is to periodically check your DOM size and depth . I know this sounds obvious, but since we typically work with UI components or template partials that only expose us to a bit of HTML at a time, it’s easy to forget about how these bits of markup add up.
5
6 reads
Another thing that helps a lot is reducing the scope and complexity of your CSS selectors . This gives the browser an easier time finding the elements you’re trying to target and helps perform style recalculations much faster.
5
5 reads
IDEAS CURATED BY
CURATOR'S NOTE
How the DOM tree size is actually affects your page load speed
“
Similar ideas
11 ideas
Cumulative Layout Shift: What It Is and How to Measure It
blog.hubspot.com
12 ideas
Testing · React Native
reactnative.dev
2 ideas
Read & Learn
20x Faster
without
deepstash
with
deepstash
with
deepstash
Personalized microlearning
—
100+ Learning Journeys
—
Access to 200,000+ ideas
—
Access to the mobile app
—
Unlimited idea saving
—
—
Unlimited history
—
—
Unlimited listening to ideas
—
—
Downloading & offline access
—
—
Supercharge your mind with one idea per day
Enter your email and spend 1 minute every day to learn something new.
I agree to receive email updates