ajax minifier
The Babel toolchain is amazing. We've used Babel to well before ES6 features hit browsers, we use it to parse JavaScript and write JSX, and much more. Babel can do just about anything with the JavaScript language and I've just learned of another use for the Babel toolchain: .
Babel工具链很棒。 在ES6功能进入浏览器之前,我们已经使用Babel ,我们使用它来解析JavaScript和编写JSX等。 Babel可以使用JavaScript语言执行几乎所有操作,而且我刚刚了解到Babel工具链的另一种用途: 。
At the time of its creation, many other JavaScript minifiers weren't capable of ES6 minifying but when you have an amazing, forward-thinking parser like Babel, creating an ES6+ aware minifier becomes much easier.
在创建它时,许多其他JavaScript压缩程序都无法进行ES6压缩,但是当您拥有像Babel这样令人惊叹的,具有前瞻性的解析器时,创建支持ES6 +的压缩程序将变得更加容易。
从命令行使用babili (Using babili from Command Line)
I prefer to use babili from command line when doing a quick minification:
快速缩小时,我更喜欢从命令行使用babili:
// Sample source code:class Mangler { constructor(program) { this.program = program; }}new Mangler(); // without this it would just output nothing since Mangler isn't used// Before:// ES2015+ code -> Babel -> Babili/Uglify -> Minified ES5 Codevar a=function a(b){_classCallCheck(this,a),this.program=b};new a;// After:// ES2015+ code -> Babili -> Minified ES2015+ Codeclass a{constructor(b){this.program=b}}new a;
Note that babili does not transpile ES5 JavaScript before minifying -- you'll need to use an excellent tool like to get ES6+ from ES5. Assuming you do have ES6 in your source file, you'll notice all of your code has been elegantly minified by babili!
需要注意的是巴比利不 transpile ES5JavaScript涅槃之前-你需要使用像一个很好的工具从ES5来获得ES6 +。 假设您的源文件中确实有ES6,您会发现babili巧妙地缩小了所有代码!
通过Node.js使用babili (Using babili via Node.js)
Being a JavaScript parser implemented in JavaScript, babili is also available for use via Node.js APIs. There are also dozens of you can use to customize your minification. Check out the documentation for and Node.js usage information.
babili是用JavaScript实现JavaScript解析器,也可以通过Node.js API使用。 您还可以使用数十个来自定义缩小版本。 查阅文档以获取和Node.js使用信息。
Babel has had as much of an impact on writing JavaScript for the web as any popular JavaScript frameworks and will continue to do so in the future. If you haven't explored the and it's plethora of plugins, take the time to give them a look. Being able to write and experiment with edge JavaScript language features before they hit the browsers is an advantage to any developer, whether it be in getting them a job or simply keeping them up to speed with the language.
Babel与任何流行JavaScript框架一样,对Web上JavaScript产生了很大的影响,并且将来会继续这样做。 如果您还没有探索并且它有太多的插件,请花一些时间看看它们。 对于开发人员来说,能够在边缘JavaScript语言功能进入浏览器之前对其进行编写和试验是一个优势,无论是让他们找到一份工作,还是简单地使其与语言保持同步。
翻译自:
ajax minifier