Front end developer specialising in JavaScript and React. Experienced in all aspects of modern front end development. Passionate about making accessible, secure and performant software.
Babel on its own is not a magic bullet—you need to include the right polyfill with it, since it's not a language feature. But your point is valid and the polyfills are easy.
IE11 is ~2%, for me on any modern content site, I just don't ship it any JS whatsoever. This is what we did for e.g. the Chrome Dev Summit site.
Front end developer specialising in JavaScript and React. Experienced in all aspects of modern front end development. Passionate about making accessible, secure and performant software.
Front end developer specialising in JavaScript and React. Experienced in all aspects of modern front end development. Passionate about making accessible, secure and performant software.
:(, sorry you lost days on this. Yeah in my experience polyfill issues are tricky to debug. You're right, Babel needs a polyfill for DOM methods. element-closest-polyfill seems to do the job well.
In the future, if you want to polyfill a lot of stuff automatically, Babel recommends using core-js and regenerator-runtime/runtime. (It mentions it at the top of the page for the deprecated babel/polyfill). However, those can be a lot of work and configuration, so specific polyfills like element-closest-polyfill are very good.
Hi, thanks for your reply.
I looked for a regenerator-runtime/runtime config with Rollup and Babel.
Didn't find so I ended up with temporary element-closest-polyfill.
Thanks for your answer.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Good post!
And if you need to support IE11, the polyfill is very light. You can find examples on the MDN pages:
Or you can just use Babel.
Babel on its own is not a magic bullet—you need to include the right polyfill with it, since it's not a language feature. But your point is valid and the polyfills are easy.
IE11 is ~2%, for me on any modern content site, I just don't ship it any JS whatsoever. This is what we did for e.g. the Chrome Dev Summit site.
Yeah you need to include the Babel polyfill properly.
Haha, I'm jealous. Unfortunately the website I'm working on is B2B focused which has a significant number of enterprise users in IE11. Ah well.
Babel doesn't polyfill DOM methods.
I lost 3 days on this and ended with
npm i --save-dev element-closest-polyfill
import 'element-closest-polyfill'
:(, sorry you lost days on this. Yeah in my experience polyfill issues are tricky to debug. You're right, Babel needs a polyfill for DOM methods.
element-closest-polyfill
seems to do the job well.In the future, if you want to polyfill a lot of stuff automatically, Babel recommends using core-js and regenerator-runtime/runtime. (It mentions it at the top of the page for the deprecated babel/polyfill). However, those can be a lot of work and configuration, so specific polyfills like
element-closest-polyfill
are very good.Hi, thanks for your reply.
I looked for a regenerator-runtime/runtime config with Rollup and Babel.
Didn't find so I ended up with temporary element-closest-polyfill.
Thanks for your answer.