core-js v3: Choosing Polyfill Imports for Older Browser Support
How to choose between global, selective, and Babel-driven core-js v3 polyfills without bloating your bundle or patching built-ins recklessly.
31 Jul 2026, 10:46 UTC

Decide which core-js imports to ship
You need your application to run on older browsers, but shipping every available polyfill to every visitor wastes bandwidth and parse time. core-js v3 provides polyfills for finished ECMAScript features such as Promise, Array.prototype.flat, Object.fromEntries, and String.prototype.matchAll. The engineering decision is not whether to use core-js, but how to import it: globally, feature by feature, or automatically through a build-tool preset based on your supported browser list.
Useful takeaway: prefer feature-specific imports or Babel-driven injection over core-js/stable unless you have many legacy targets and no time to maintain a browser list. Avoid core-js proposals in long-lived production code because stage 3 APIs can change before standardization.
Constraints to set first
- Oldest browser versions you must support (for example, IE 11 or a specific Safari version).
- JavaScript bundle size budget.
- Whether your project already uses Babel, webpack, Rollup, or another bundler.
- Whether third-party dependencies assume global built-ins are already patched.
Supported import styles compared
| Import style | Behavior | Global side effects | Best suited for |
|---|---|---|---|
core-js/stable | Polyfills all finished ECMAScript features in one import. | Yes; modifies built-in prototypes and globals. | Rapid migration with many old targets. |
core-js/es/* | Imports individual features, such as core-js/es/promise. | No automatic global patching for the import itself. | Fine-grained control and smaller bundles. |
@babel/preset-env with core-js | Injects only the polyfills your code and targets require. | Configurable; usage mode avoids global entry imports. | Projects with a defined browserslist and build step. |
Trade-offs
core-js/stable is the simplest to add: one import at the top of your entry file covers most finished features. The cost is a larger bundle and global modifications to built-ins, which can conflict with libraries or future native implementations. Selective imports keep the bundle smaller but require you to know which features your code uses and import them before application code runs. Babel preset-env automates that selection, but it couples your polyfill strategy to your build configuration and browser targets.
core-js v2 is end-of-life. New projects should use core-js v3 or later and pin the minor version in package.json to avoid breaking changes from polyfill behavior updates. Proposals under core-js/proposals are version-sensitive and may be removed or changed as specifications advance; do not rely on them for production APIs without a pin and a review process.
Concrete setup: Babel preset-env
Run the following in your project root to add core-js and the Babel preset:
npm install --save core-js@3 @babel/preset-env
No special permissions are required beyond write access to the project directory.
Add or update babel.config.json:
{
"presets": [
["@babel/preset-env", {
"targets": "> 0.25%, not dead, ie 11",
"corejs": { "version": "3", "proposed": false },
"useBuiltIns": "usage"
}]
]
}
targets defines the oldest browsers you support. corejs.version tells Babel to generate core-js v3 import paths. useBuiltIns: "usage" injects polyfills only where your source code uses the corresponding API, rather than importing everything up front. Verify the installed version with:
npm list core-js
Expected check: the output should show core-js@3.x.x, not v2 or a missing package.
Concrete setup: manual selective imports
If you are not using Babel, create a polyfill entry module and import it before your application code:
// src/polyfills.js
import 'core-js/es/promise';
import 'core-js/es/array/flat';
import 'core-js/es/object/from-entries';
import 'core-js/es/string/match-all';
// src/main.js
import './polyfills';
// application code starts here
Run this from your bundler's entry point. Risk: if you import a polyfill after code that already uses the API, the code may fail in older browsers. Keep polyfill imports at the very top of the dependency graph.
Validation
- Confirm
package.jsonlists"core-js": "^3.x.x"and runnpm list core-js. - Run a Node script that imports the stable set and checks for functions:
import 'core-js/stable';
console.log(typeof Array.prototype.flat);
console.log(typeof Object.fromEntries);
console.log(typeof Promise);
Expected check: each typeof expression logs "function". Do not treat this as proof that your application works in a target browser; it only confirms the polyfills loaded in Node.
useBuiltIns: "usage", you should see only the polyfills your code references, not the full core-js stable set.Limitations
- Global polyfills from
core-js/stablecan conflict with other libraries or future native implementations. useBuiltIns: "usage"may miss polyfills for code loaded dynamically or through strings, such asevalor dynamically imported templates.- Bundle size savings depend on your targets; evergreen browsers may already support the features, making some polyfills unnecessary for most visitors.
- core-js proposals are not stable APIs. Pin exact versions if you use them, and review before upgrading.
Practical result to check
After building, open your bundle analyzer and search for core-js. If you see core-js/stable or a large core-js chunk while using selective imports, your configuration is likely importing more than intended. If you see only the specific modules you listed, the import strategy is working as configured.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.