什么是 JavaScript 预编译库?
我正在学习如何使用 Magento 电子商务系统,并且我正在阅读其文档,但我不明白一些术语,“预编译的 JavaScript 库”。他们这是什么意思? JavaScript 代码如何编译?
用于升级和安装 Magento 的 Web 下载器,无需安装 使用 SSH(第 2 章中介绍)。 • js——核心文件夹,其中包含所有内容 Magento 安装中包含的 JavaScript 代码将被保留。我们 将在这里找到所有预编译的 JavaScript 库。
来源: http://www.magentocommerce.com/wiki/2_-_magento_concepts_and_architecture/magento_s_base_struct
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不知道 Magento 电子商务使用什么,但我知道 JavaScript 编译器是什么。
预编译 JavaScript 并不实用,因为各种 JavaScript 解释器都有自己的编译方法。因此,当大多数人谈论编译 JavaScript 时,他们通常指的是缩小的 JavaScript。
然而,最新的缩小器远远超出了这一范围。一个很好的例子是 Google Closure 编译器 高级模式。它与 Google Closure 库和工具相关,但即使单独使用也设计得很好。
有一个闭包编译器在线演示。
它被称为编译器,因为它不仅仅是一个压缩器,而且 JavaScript 编译器这个名称没有用于其他任何用途。例如:此代码
在高级模式下编译为
alert("Hello, New user");
。一次性函数被删除,变量名被缩短,甚至被重新使用。这是非常彻底的。简单模式假设可能涉及其他 JavaScript。在这种情况下,它将保留
hello
函数。高级模式假定只有一个 JavaScript 文件,或者它已正确导出。阻止它真正被编译的一件事是它不是像编译的 C 或 Java 那样的字节码。它仍然需要像 Perl 一样在运行时编译。
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
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.
Magento 在管理中有一个
名为合并 Javascript 文件的配置选项。
当此设置启用时,Magento 将获取它所知道的所有 javascript 文件,将它们“编译”为缩小版本以产生更小的文件大小,然后将所有 javascript 文件合并为一个 javascript 文件。这样,Magento 将打开单个网络连接来打开一个文件,而不是打开多个网络连接来下载多个文件。
因此,当文档说该文件夹包含预编译版本时,这意味着这是存储各个 javascript 文件的位置,也是在合并 Javascript 文件时加载文件的位置
。术语编译来自 < a href="http://en.wikipedia.org/wiki/Compiler" rel="noreferrer">计算机科学。编译器获取源代码,并将其从一种语言转换为另一种语言。
传统上,它意味着从更高级的语言(C、.NET、Java 等)获取代码,并将其转换为计算机芯片可以理解的机器代码(汇编代码)。然而,该术语是通用的,更现代的用法包括采用一种语言(Javascript)编写的源代码并将其转换为不同的形式(缩小的 JavaScript)。
Magento has an configuration option in the admin at
named Merged Javascript Files.
When this setting is on, Magento will take all the javascript files it knows about, "compile" them to a minified version to product smaller files sizes, and then combine all the javascript files into a single javascript file. This way, instead of opening multiple network connections to download multiple files, Magento will open a single network connection to open one file.
So, when the documentation says that folder contains the pre-compiled versions, it means that's where the individual javascript files are stored, and where the files are loaded from when Merged Javascript Files
The term compilation comes from Computer Science. A compiler takes source code, and transforms it from one language into another language.
Traditionally, it's meant taking code from a higher level language (C, .NET, Java, etc.), and transforming it into the machine code (assembly code) that's understood by the computer chip. However, the term is generic and more modern usage includes taking the source code written in one language (Javascript) and transforms it into a different form (minified javascript).