什么是JavaScript预编译库? [英] What is a JavaScript pre-compiled library?

查看:118
本文介绍了什么是JavaScript预编译库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在学习如何使用 Magento 电子商务系统,阅读其文档,但我不理解预编译的JavaScript库"这个术语.那是什么意思?如何编译JavaScript代码?

无需下载即可升级和安装Magento的网络下载器 使用SSH(覆盖第2章). •js-所有的核心文件夹 保留Magento安装中随附的JavaScript代码.我们 将在此处找到所有预编译的JavaScript库.

来源: http://www.magentocommerce.com/wiki/2_-_magento_concepts_and_architecture/magento_s_base_structure

解决方案

我不知道Magento电子商务使用了什么,但是我知道JavaScript编译器是什么.

预编译的JavaScript不切实际,因为各种JavaScript解释器将具有自己的编译方法.因此,当大多数人谈论编译JavaScript时,他们通常指的是Minified JavaScript.

但是,最新的缩小器已经超越了.一个很好的例子是 Google Closure编译器 Google Closure库和工具相关,但即使单独使用,也经过精心设计. >

有一个 closure编译器在线演示.

之所以称为编译器,是因为它不仅是一个缩小器,而且JavaScript编译器这个名称也没有用于其他任何用途.例如:这段代码

function hello(name) {
  alert('Hello, ' + name);
}
hello('New user');

在高级模式下编译为alert("Hello, New user");.删除了一次性功能,缩短了变量名称,甚至重新使用了.

这是非常彻底.简单模式假定可能还涉及其他JavaScript.在这种情况下,它将保留hello函数.进阶模式假设只有一个JavaScript档案,或已正确汇出.

使它无法真正被编译的一件事是,它不是像编译后的C或Java那样的字节码.它仍然必须像Perl一样在运行时进行编译.

I'm learning how to use Magento e-commerce system, and I'm reading its documentation, but I don't understand some term, a "pre-compiled JavaScript library". What do they mean by that? How can JavaScript code be compiled?

The web downloader for upgrading and installing Magento without the use of SSH (covered in Chapter 2). • js—The core folder where all JavaScript code included with the installation of Magento is kept. We will find all pre-compiled libraries of JavaScript here.

Source: http://www.magentocommerce.com/wiki/2_-_magento_concepts_and_architecture/magento_s_base_structure

解决方案

I do not know what Magento e-commerce uses, but I know what JavaScript Compilers are.

Pre-Compiled JavaScript is not practical as the various JavaScript interpreters will have their own method of compiling. Therefore, when most people talk about Compiling JavaScript, they are usually referring Minified JavaScript.

However, the latest minifiers go way beyond. A good example is Google Closure Compiler Advanced Mode. It is related to Google Closure Library and Tools, but is well designed even when used by itself.

There is an Online Demo of Closure Compiler.

It is called a Compiler because it is more than a minifier and the name JavaScript Compiler is not used for anything else. For example: This code

function hello(name) {
  alert('Hello, ' + name);
}
hello('New user');

compiles to alert("Hello, New user"); in advanced mode. Single-use functions are removed, variable names are shortened, and even re-used.

It is very thorough. Simple mode assumes that there might be other JavaScript involved. in which case it would preserve the hello function. Advanced mode assumes that there is only a single JavaScript file, or that it is properly exported.

The one thing that keeps this from really being compiled is that it is not bytecode like compiled C or Java would be. It still has to be compiled at run-time like Perl.

这篇关于什么是JavaScript预编译库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆