Skip to content
Tech News
← Back to articles

The three pillars of JavaScript bloat

read original get JavaScript Performance Optimization Kit → more articles
Why This Matters

This article highlights the growing issue of JavaScript dependency bloat, emphasizing how outdated support and redundant code contribute to larger, less efficient projects. Addressing these three pillars of bloat can lead to more streamlined, maintainable, and performant JavaScript applications, benefiting both developers and end-users.

Key Takeaways

The Three Pillars of JavaScript Bloat

Over the last couple of years, we’ve seen significant growth of the e18e community and a rise in performance focused contributions because of it. A large part of this is the “cleanup” initiative, where the community has been pruning packages which are redundant, outdated, or unmaintained.

One of the most common topics that comes up as part of this is “dependency bloat” - the idea that npm dependency trees are getting larger over time, often with long since redundant code which the platform now provides natively.

In this post, I want to briefly look at what I think are the three main types of bloat in our dependency trees, why they exist, and how we can start to address them.

1. Older runtime support (with safety and realms)

The graph above is a common sight in many npm dependency trees - a small utility function for something which seems like it should be natively available, followed by many similarly small deep dependencies.

So why is this a thing? Why do we need is-string instead of typeof checks? Why do we need hasown instead of Object.hasOwn (or Object.prototype.hasOwnProperty )? Three things:

Support for very old engines Protection against global namespace mutation Cross-realm values

Support for very old engines

Somewhere in the world, some people apparently exist who need to support ES3 - think IE6/7, or extremely early versions of Node.js.

... continue reading