+ 1

[SOLVED] Render ES 6 for browsers that support it

Presently many browsers do support most ES 6 features. So instead of transpiling to ES 5 with babel for all browsers, I want to detect if a browser supports a feature. If it does I use the feature else I use the ES 5 alternative. But that is a lot of work for something so trivial. Is there a package or software that helps with that?

16th Jun 2020, 9:22 AM
Ore
Ore - avatar
6 Respuestas
+ 3
Yeah there is search for "feature-detect-es6" on your browsers and see how it works
22nd Jun 2020, 10:15 AM
boolean
boolean - avatar
+ 2
Then use the try and catch to detect eg try{ var z=()=>{ document.write("Gud");} z(); document.write("Supported") } catch(exception){ document.write("Not Supported") }
22nd Jun 2020, 5:35 AM
boolean
boolean - avatar
+ 2
Yeah its pure javascript no npm package needed
22nd Jun 2020, 6:20 AM
boolean
boolean - avatar
+ 1
boolean Thanks. That is exactly what I wanted.
22nd Jun 2020, 4:59 PM
Ore
Ore - avatar
0
boolean So no npm package for that?
22nd Jun 2020, 5:58 AM
Ore
Ore - avatar
0
boolean You don't understand me. My question is whether there is an npm package that helps with that. I know I can manually do it but for a large script it is a lot of work.
22nd Jun 2020, 8:25 AM
Ore
Ore - avatar