airbnb / polyglot.js

Give your JavaScript the ability to speak many languages.
http://airbnb.github.io/polyglot.js
BSD 2-Clause "Simplified" License
3.71k stars 208 forks source link

Polyfills make up over 75% of package size #165

Closed erikt9 closed 2 years ago

erikt9 commented 2 years ago

When bundling with webpack, polyglot.js takes up 91k of space (unminified). If I alias the polyfill dependencies of this library 'string.prototype.trim', 'object.entries', 'array.prototype.foreach' to implementations that simply call the modern browser functionality, the bundle is 20K.

Given the dominating percentage of the overall package size the polyfills are consuming, it may be best to remove them and allow the developer to supply them if they so choose. At the very least, it may be time for the polyfills 'string.prototype.trim' and 'array.prototype.foreach' to be removed as these are long standard ES5 features.

ljharb commented 2 years ago

No, it would be insanely harmful to remove them, given how easy it is for you to remove them in your bundled if and only if you know that your application doesn't need them.

Polyfills should and will remain for eternity, because it's the safest default, always.