How to convert es6 to es5 using babel, non node js environment

192 Views Asked by At

Please I am trying to convert my javascript code to es5 using babel but It's not working. I can't seem to get it done.

I am using babel standalone to do this because I'm using a non node js environment. I have linked to the standalone as per the documentation...

<script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>

I have also changed the script tag type to type="text/babel" I also specified this data-type="module" so that it goes with the browser's native support for ES Modules.

But this seems not to work still. And by work I mean the javascript code isn't running on older browsers because of support. I am trying to get my code to work on lg webOS tv 3.0 and from their site, that version of lg webOs tv doesn't support ES6.

I tried using presets from some answers on similar questions but it still didn't work. Mostly because the presets are

<script type="text/babel" data-presets="es2015,stage-3">
<script type="text/babel" data-presets="es2017,stage-2">

Tried both of them and I couldn't still get the browser to run the javascript code. Also it's more jquery than javascript. Infact it's 80% jquery. I can't post the code here because it's huge. There's nothing wrong with code because it runs fine on modern browsers. Only get this problem on lg webOs tv 3.0

1

There are 1 best solutions below

0
On BEST ANSWER

Couldn't use babel unfortunately. Wasn't working. I used traucer instead. Easy to use and get started, especially for non-node js environments