console.log([1, 2, 3].at(-1)) transpiles to 44k
Based on The PrimeTime's video on YouTube. If you like this content, support the original creators by watching, liking and subscribing to their content.
A small modern feature like `Array.prototype.at(-1)` can expand to ~44 KB of minified ES5 output when transpilation triggers broad polyfill/helper injection.
Briefing
A single modern JavaScript feature—`Array.prototype.at(-1)`—can balloon from a tiny snippet into tens of kilobytes of ES5-era helper code when legacy support is handled through transpilation plus polyfills. The core point is less about `at()` itself and more about the real-world cost of targeting old browsers: legacy compatibility often turns into “download it everywhere, use it nowhere,” especially when build defaults and library packaging don’t line up.
The discussion starts with a concrete size shock. Logging `[1, 2, 3].at(-1)` becomes roughly 44 KB of minified ES5 output after transpilation and polyfill injection. The example is used to show why: Babel/Core-js-style support requires large bundles of runtime machinery (descriptors, symbols, regex-related helpers, and other edge-case coverage) even when the original code doesn’t need those complexities. That cost is not just theoretical—supporting legacy browsers can force developers to ship far more code than the feature actually requires.
From there, the focus shifts to whether this bloat helps anyone. Using HTTP Archive-style measurements across the most popular sites, the analysis finds that a large majority of websites still serve untranspiled ES6+ syntax in production, while many also include ES5 helper libraries in the same bundles. Even more striking: many sites that ship ES5 helper code still fail to work in IE11. In other words, users on the one browser that needs the legacy helpers are often not getting a working experience, while everyone else pays the download cost.
The root causes are traced to three layers that interact badly: (1) default configurations in popular bundlers/build tools, (2) how widely used libraries publish their builds (often with ES5 helper dependencies and/or ES6+ code paths), and (3) the common practice of excluding `node_modules` from transpilation. That exclusion speeds builds and avoids needless work, but it also means library code may slip through untranspiled—producing ES6+ syntax in production—while the site still carries ES5 helpers for other reasons.
The recommendations follow logically. ES5 should no longer be treated as a default compilation target for modern production. Build tools and libraries should avoid hard-coding a fixed legacy browser policy; instead, they should let website developers choose targets based on their actual audience. Library authors, in particular, are urged to publish standard, modern JavaScript and avoid deciding legacy compatibility for every consumer—because library authors lack visibility into each importing site’s deployment constraints and build pipeline.
The practical takeaway is a shift in responsibility: cross-browser support should be a website build decision, not something silently imposed by library packaging defaults. Baseline-style feature targeting is presented as a more future-proof approach than clinging to ES5, since it updates with browser support rather than freezing the ecosystem in an older compatibility era.
Cornell Notes
The transcript argues that legacy-browser support often creates massive, unnecessary payloads when modern JavaScript is transpiled to ES5 with polyfills. A small example (`[1,2,3].at(-1)`) can turn into ~44 KB of minified output, illustrating how polyfill machinery covers many edge cases. Real-world measurements across the top websites suggest many bundles include both ES5 helper code and untranspiled ES6+ syntax, and some still fail in IE11—meaning the legacy cost is paid without delivering legacy benefit. The proposed fix is to stop treating ES5 as a default target and instead let website developers choose browser targets, while library authors publish standard modern code that can be transpiled by the consumer’s build system.
Why can a single modern JS feature produce tens of kilobytes of ES5 output?
What does the analysis claim about ES5 helper code and IE11 in production?
How do untranspiled ES6+ scripts and ES5 helpers end up in the same bundle?
What role do build-tool defaults play?
Why does the transcript say library authors should stop targeting ES5 by default?
What alternative is proposed to replace fixed ES5 targeting?
Review Questions
- What mechanisms make polyfill-based transpilation disproportionately large compared with the original modern code?
- How can excluding `node_modules` from transpilation lead to both untranspiled ES6+ syntax and ES5 helper code appearing together?
- Why does shifting responsibility from library authors to website developers change the likely outcome for legacy browser support?
Key Points
- 1
A small modern feature like `Array.prototype.at(-1)` can expand to ~44 KB of minified ES5 output when transpilation triggers broad polyfill/helper injection.
- 2
Real-world measurements suggest many top websites ship ES5 helper code yet still fail in IE11, creating “legacy cost without legacy benefit.”
- 3
Bundler/build defaults and the common practice of excluding `node_modules` from transpilation can leave ES6+ syntax untranspiled in production.
- 4
The transcript argues that ES5 should not be the default compilation target for modern production builds.
- 5
Library authors are urged to publish standard modern JavaScript rather than forcing ES5 compatibility decisions onto every consumer.
- 6
Cross-browser support should be chosen by website developers (based on actual audience needs), not assumed by library packaging defaults.
- 7
Baseline-style feature targeting is presented as a more future-proof approach than fixed ES5/IE11 policies.