[翻译]High Performance JavaScript(028)
JavaScript Minification JavaScript紧凑
JavaScript minification is the process by which a JavaScript file is stripped of everything that does not contribute to its execution. This includes comments and unnecessary whitespace. The process typically reduces the file size by half, resulting in faster downloads, and encourages programmers to write better, more extensive inline documentation.
JavaScript紧凑指的是剔除一个JavaScript文件中一切运行无关内容的过程。包括注释和不必要的空格。该处理通常可将文件尺寸缩减到一半,其结果是下载速度更快,并鼓励程序员写出更好,更详细的内联文档。
JSMin (http://www.crockford.com/javascript/jsmin.html), developed by Douglas Crockford, remained the standard in JavaScript minification for a long time. However, as web applications kept growing in size and complexity, many felt it was time to push JavaScript minification a step further. This is the main reason behind the development of the YUI Compressor (http://developer.yahoo.com/yui/compressor/), a tool that performs all kinds of smart operations in order to offer a higher level of compaction than other tools in a completely safe way. In addition to stripping comments and unnecessary whitespace, the YUI Compressor offers the following features:
JSMin(http://www.crockford.com/javascript/jsmin.html),由Douglas Crockford开发,它保持了JavaScript紧凑标准很长一段时间。然而随着网络应用程序在规模和复杂性上不断增长,许多人认为JavaScript紧凑应当再向前推进一步。这是开发YUI压缩器的主要原因(http://developer.yahoo.com/yui/compressor/)它提供了所有类型的智能操作,为了提供比其它工具更高级的紧凑操作并且以完全安全的方法实现。除了剔除注释和不必要的空格,YUI压缩器还提供以下功能:
• Replacement of local variable names with shorter (one-, two-, or three-character) variable names, picked to optimize gzip compression downstream
将局部变量名替换以更短的形式(1个,2个,或3个字符),以优化后续的gzip压缩工作
• Rep
相关文档:
Repaints and Reflows 重绘和重排版
Once the browser has downloaded all the components of a page—HTML markup, JavaScript, CSS, images—it parses through the files and creates two internal data structures:
当浏览器下载完所有页面HTML标记,JavaScri ......
Conditionals 条件表达式
Similar in nature to loops, conditionals determine how execution flows through JavaScript. The traditional argument of whether to use if-else statements or a switch statement applies to JavaScript just as it does to other languages. Since different b ......
第五章 Strings and Regular Expressions 字符串和正则表达式
Practically all JavaScript programs are intimately tied to strings. For example, many applications use Ajax to fetch strings from a server, convert those strings into more easily usable JavaScript objects, and ......
第七章 Ajax 异步JavaScript和XML
Ajax is a cornerstone of high-performance JavaScript. It can be used to make a page load faster by delaying the download of large resources. It can prevent page loads altogether by allowing for data to be transferred between the client ......
第八章 Programming Practices 编程实践
Every programming language has pain points and inefficient patterns that develop over time. The appearance of these traits occurs as people migrate to the language and start pushing its boundaries. Since 2005, when the term "Ajax" ......