When is a second legacy build worth it over one web build lowered for everyone, if the app must also run on older kiosk browsers?
answer
- who pays for the oldest browser
- modern-only, single lowered, or both
- helpers, generator runtime, polyfill bundle
- a loader standing in for modules
- twice the build, twice the testing
basics
~20 sA second legacy build pays off when old browsers are a small but required share: modern browsers keep the lean modern bundle and only kiosks download the lowered, polyfilled copy. Otherwise one lowered build is simpler to ship and test.
solid answer
~50 sOne build lowered to the kiosk's level is simplest, with one artifact and one test pass, but every phone then downloads rewritten syntax, helpers, a generator runtime for async code and polyfills it does not need. A modern-only build is smallest and simply fails on the kiosks. A second legacy build splits the cost: each chunk is emitted twice, the modern copy loaded as module scripts and the legacy copy, lowered further with a polyfill bundle and often a small loader that stands in for native modules and `import()`, loaded through the `nomodule` fallback. You pay in build time, two outputs to test, inline loader scripts a strict content policy must allow, and engines the module test misclassifies. It earns its keep when legacy traffic is real but small; if the kiosks are one fleet you control, upgrading them or targeting that one browser may be cheaper.
go deeper
Know the three shapes: modern-only, one build lowered for everyone, and a modern plus a legacy build, and which browsers load which bundle.
Explain what lowering for an old engine adds, from helpers and a generator runtime to polyfills and a module loader, and why every visitor pays for it in a single build.
Show the production judgment: measure the size and speed gap, handle module-capable engines that still lack features, account for inline scripts and test two outputs before choosing a split.
Frame it as a support policy: which share of legacy traffic justifies two builds per release, and when upgrading or separating a controlled fleet is the cheaper decision.
## Three shapes of build A transit app that must work on ticket-hall kiosks with an older embedded browser, as well as on current phones, can be built in three ways: | Shape | What ships | Who pays | What breaks | |---|---|---|---| | **Modern-only** | one bundle with a recent target | nobody pays extra | the kiosks fail to parse or run it | | **Single lowered build** | one bundle lowered and polyfilled for the oldest kiosk | every visitor, including phones | nothing, if the target is right | | **Modern plus legacy** | a modern bundle and a separately lowered legacy bundle | only the browsers that load the legacy copy | engines the split misclassifies | The question is not which shape is correct but who should carry the cost of the oldest browser you support. ## What lowering for an old engine adds Lowering for an engine that lacks modern syntax and built-ins adds more than rewritten expressions: - **Longer code** for each rewritten construct: optional chains become null checks, classes become functions with prototype assignments. - **Helper functions** for spread, destructuring and class inheritance; a bundler usually collects them into a shared module so they are not repeated in every file. - **A generator runtime** when `async` functions or generators are lowered for an engine without generators: each function becomes a state machine driven by that runtime. - **Polyfills** for every built-in the oldest target lacks. - **A module loader** when the engine cannot run `import`, `export` or `import()` natively; the legacy chunks are emitted in a format a small runtime loader can register and link. In a single lowered build, all of that reaches every visitor. Modern engines parse and execute it more slowly than the native syntax it replaced. ## How the two bundles are served In the split, the HTML loads the modern entry as a module script and the legacy entry behind the `nomodule` fallback; how those two attributes behave is an HTML subject in its own right. Engines with module support run the modern copy and skip the legacy one; engines without it do the reverse. That test is coarse. **Module support is a proxy for "modern enough", not proof.** An engine that runs module scripts but lacks something newer the modern bundle uses, such as a recent syntax feature or built-in, will load the modern copy and fail. Splits handle that with a small inline check that tests the missing features and loads the legacy copy instead, or by setting the modern target low enough to include every module-capable browser you support. ## What the split costs A second build is not a flag you turn on for free: 1. **Build time**: every chunk is transformed and emitted twice, and the legacy pass does the most work. 2. **Testing**: two outputs means two things to verify, and the legacy one only fails on devices developers rarely use. 3. **Inline scripts**: the loader bootstrap and any feature check are often inline, so a strict content security policy must allow them by hash. 4. **Debugging**: field errors arrive from two different builds, each with its own maps and chunk names. 5. **Misclassified engines**: a few historic browsers handled the module and fallback markers inconsistently, and some ran both copies; check the engines you actually support. ## Deciding Work from measurements, not habit: 1. **Find out what the kiosks run**: one exact browser version on a fleet you control is a very different problem from an unknown long tail of old phones. 2. **Measure the gap**: build both a modern bundle and a single lowered bundle for real routes and compare size, parse time and execution time on a mid-range phone. If the difference is a few polyfills, one build is usually fine. 3. **Look at the code's shape**: async-heavy code that needs a generator runtime and state machines everywhere makes the single lowered build much heavier, and the split more attractive. 4. **Consider the cheaper exits**: upgrading the kiosk browser, giving the kiosks their own deployment, or naming that one browser in the target can beat maintaining two builds for every release. - Choose **single lowered** when the legacy share is large or the size difference is small. - Choose **modern plus legacy** when legacy traffic is small but must work and the lowering cost is large. - Choose **modern-only** only when you can tell the kiosk owner to upgrade.
- What if the kiosk browser supports module scripts but lacks some newer syntax?Then the module/nomodule split alone sends it the modern bundle, and that bundle fails. Either the modern build's target must include that browser, or a small inline check must test for the missing features and load the legacy bundle instead. The check adds an inline script, and module-capable browsers start loading the modern entry before falling back.
- Why is a legacy build's output often wrapped in a different module format?Because an engine without native module support cannot run `import`, `export` or `import()` at all. The legacy build therefore emits chunks in a format a small runtime loader can register and link, emulating static imports and lazy loading. That loader is extra code that only the legacy path pays for.
- How do you decide whether the saving for modern browsers justifies the split?Build both shapes and compare them on real routes: transferred size, parse and execution time on a mid-range phone, and how much of the difference comes from helpers and generator state machines. If lowering for the kiosks adds little, one build is simpler; if async-heavy code makes the lowered bundle much heavier, the split usually earns its extra build and test cost.
- A single build lowered for the kiosks costs modern phones nothing.
- The legacy build only needs syntax lowering, never polyfills or a loader.
- Every modern browser downloads and runs both bundles in the split.
- A legacy build is a switch with no build-time or testing cost.
- Any browser that runs module scripts can run the modern bundle.