Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using babel-standalone in the browser

I am using babel-standalone and I am doing the exact same thing as https://github.com/Daniel15/babel-standalone/blob/master/examples/scriptTag-src.htm, but I get the warning

You are using the in-browser Babel transformer. Be sure to precompile your scripts for production - https://babeljs.io/docs/setup/

I don't know what to do. Shouldn't it just translate all my ES6 code to code supported by older browsers?

like image 944
Jamgreen Avatar asked Oct 11 '16 18:10

Jamgreen


People also ask

How do you use Babel standalone?

Use it via UNPKG: https://unpkg.com/@babel/standalone/babel.min.js. This is a simple way to embed it on a webpage without having to do any other setup. Install via NPM: npm install --save @babel/standalone.

Can I use Babel without Webpack?

If you just want to get started on React real quick and you don't mind using require or import in your code, then babel could be enough to jump start your React project. Say for example that all your javascript files are in the ./src folder, you can bundle them into one file with this command.

Is Babel a standalone?

And unlike The Poppy War Trilogy, which I consider a grimdark fantasy series, Babel is a standalone dark academia novel.

Does Babel need node?

If you've been active as a Node. js developer, or even dabbled in front-end libraries like React or Vue. js, then there's no doubt that you've likely run across Babel.


1 Answers

It's just a warning, nothing to worry about.

It's just telling you that you shouldn't run Babel in the browser on production sites, because running Babel in the browser is slower than precompiling your files with Babel, because the browser will have to compile your files every time you open a page. But if you're running it for development or personal pages, or if you just don't care (e.g., you don't have that much code), you won't need to worry about this warning.

like image 101
Frxstrem Avatar answered Sep 18 '22 07:09

Frxstrem