Get AI summaries of any video or article — Sign up free
console.log([1, 2, 3].at(-1)) transpiles to 44k thumbnail

console.log([1, 2, 3].at(-1)) transpiles to 44k

The PrimeTime·
5 min read

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.

TL;DR

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?

Because transpiling plus polyfills isn’t limited to the exact feature used. Supporting `Array.prototype.at(-1)` in ES5 requires runtime helper code that covers many edge cases and specification details (e.g., descriptors, symbols, regex-related helpers). Even when the original code is simple, the compatibility layer can be large, turning a ~31-byte snippet into ~44,000 bytes minified in the example.

What does the analysis claim about ES5 helper code and IE11 in production?

It reports that many popular sites ship ES5 helper libraries yet still don’t work in IE11. The key pattern is “download legacy helpers everywhere, but IE11 users still fail,” implying the transpilation/polyfill strategy doesn’t reliably produce a working legacy bundle.

How do untranspiled ES6+ scripts and ES5 helpers end up in the same bundle?

A common setup excludes `node_modules` from transpilation. If a dependency publishes ES6+ syntax (or a site’s bundler defaults pull in an ES6 build), that syntax can remain untranspiled. Meanwhile, other parts of the toolchain still inject ES5 helper code, so the final output can contain both ES6+ syntax and ES5 helper libraries in the same served scripts.

What role do build-tool defaults play?

Defaults often determine the browser targets and whether ES5 is produced. The transcript notes that some tools (notably Babel when targets aren’t specified) can transpile broadly to ES5, while newer tools may not support ES5 at all. Since many developers rely on defaults, the default target policy can unintentionally keep legacy transpilation in place.

Why does the transcript say library authors should stop targeting ES5 by default?

Library authors can’t know each consumer site’s browser support needs or build pipeline. If a library ships ES5-transpiled output, it forces every importing site to carry legacy compatibility decisions—even when the site doesn’t need them. The suggested approach is to publish standard modern JavaScript and let the importing site transpile based on its own targets.

What alternative is proposed to replace fixed ES5 targeting?

Feature-baseline targeting (described via Baseline) is presented as a way to target widely supported, stable features that evolve over time. The idea is to compile/transpile based on current browser feature availability rather than freezing compatibility around ES5 and IE11-era assumptions.

Review Questions

  1. What mechanisms make polyfill-based transpilation disproportionately large compared with the original modern code?
  2. How can excluding `node_modules` from transpilation lead to both untranspiled ES6+ syntax and ES5 helper code appearing together?
  3. Why does shifting responsibility from library authors to website developers change the likely outcome for legacy browser support?

Key Points

  1. 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. 2

    Real-world measurements suggest many top websites ship ES5 helper code yet still fail in IE11, creating “legacy cost without legacy benefit.”

  3. 3

    Bundler/build defaults and the common practice of excluding `node_modules` from transpilation can leave ES6+ syntax untranspiled in production.

  4. 4

    The transcript argues that ES5 should not be the default compilation target for modern production builds.

  5. 5

    Library authors are urged to publish standard modern JavaScript rather than forcing ES5 compatibility decisions onto every consumer.

  6. 6

    Cross-browser support should be chosen by website developers (based on actual audience needs), not assumed by library packaging defaults.

  7. 7

    Baseline-style feature targeting is presented as a more future-proof approach than fixed ES5/IE11 policies.

Highlights

`[1, 2, 3].at(-1)` turns into roughly 44 KB of minified ES5 output—an example of how polyfills can dwarf the original code.
Many popular sites appear to ship both ES5 helper libraries and untranspiled ES6+ syntax, and some still don’t work in IE11.
The “exclude `node_modules` from transpilation” default can cause dependencies to leak ES6+ syntax into production bundles.
The proposed shift: stop defaulting to ES5; let website developers decide targets, and have library authors publish modern, standard code.

Topics

  • ES5 Transpilation
  • Polyfill Bloat
  • IE11 Compatibility
  • Build Tool Defaults
  • Library Packaging

Mentioned

  • ES5
  • ES6
  • IE11
  • HTTP Archive
  • Babel
  • core-js
  • TS
  • TS lib
  • JS comp
  • W3C
  • LSP
  • DOM
  • WASM
  • IE