How to preprocess the es6, in html to make it compatible with browsers?

here are the babel and es6 writings introduced in html

   

The

browser outputs, but prompts that you are using an in-browser Babel converter. Be sure to precompile the script for the production environment . Is there any way to deal with the es6 in html?

Mar.29,2022

because you use babel.min.js in the browser to compile the ES6 syntax in real time, which is very performance-consuming, and it is usually only used in testing or temporary environments (codepen, etc.), so the page will give you a warning not to use it directly in the production environment.

the right thing to do is to run the compiled js file back to the browser, usually through tools such as webpack , and then give the generated file to the formal environment. If you don't know webpack or find it troublesome, you can compile it directly in babel .

clipboard.png


first compile to ES5 through the babel command, and then put it into html

Menu