Load polyfills from polyfill.io rather than babel-polyfill
See original GitHub issuebabel-polyfill
is very heavy, and the REPL loads it when you select the “evaluate” option. Let’s instead use a conditional polyfilling service like polyfill.io
that only loads the polyfills your browser actually needs. I’d say that most users of the REPL would be using a relatively modern browser, so this should reduce load time.
We’ll need to be sure to load the regenerator runtime though.
import "regenerator-runtime/runtime";
Issue Analytics
- State:
- Created 6 years ago
- Comments:11 (9 by maintainers)
Top Results From Across the Web
How to load polyfills only when needed
The best solution would be a custom one: something that combines benefits of polyfill.io and Babel's useBuiltIns but doesn't incur their costs.
Read more >babel/polyfill
Babel includes a polyfill that includes a custom regenerator runtime and core-js. This will emulate a full ES2015+ environment (no < Stage 4...
Read more >Differential serving vs. polyfill service: How to ... - Dong Chen
Instead, babel will import the corresponding polyfills on top of each of your file. Also, you don't need to worry about including the...
Read more >Polyfills and transpilers - The Modern JavaScript Tutorial
js and polyfill.io do. Anyway; to make things a little bit more confusing Babel in addition to transpiling has some sort of post-process...
Read more >Why do I need @babel/polyfill at all, using Babel?
Both polyfill and transpilation enable you to use new features in old environments (think of old vs new browsers for example), ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@thedamon by my opinion,
polyfill.io
is a good service with bad polyfills.You can see
polyfill.io
position about the correctness of polyfills here. You can check the source code of polyfills frompolyfill.io
in their repo. Just an example - leakingWeakMap
polyfill. They have some progress in the previous year, but because they regularly have issues like this, I can’t recommend it for usage.polyfill.io
use polyfills from different authors/projects which doesn’t well play together.core-js
/babel-polyfill
includes much more features thanpolyfill.io
. Just some example -regenerator
runtime for generators / async functions, polyfills for ES proposals, typed arrays, the logic of almost all well-known symbols, etc.105kb of
babel-polyfill
you will have only with full bundle, but it’s modular. You can load only required part ofcore-js
. You can automatize this process withpreset-env
withuseBuiltIns
option.polyfill.io
service approach definitely makes sense, it can by applied tocore-js
in the future, but now I haven’t any time and motivation for working on it.I’m strictly against of usage
polyfill.io
in the REPL because it contains very incorrect polyfills and only a little part of polyfilled features frombabel-polyfill
.