[翻译]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
相关文档:
String Trimming 字符串修剪
Removing leading and trailing whitespace from a string is a simple but common task. Although ECMAScript 5 adds a native string trim method (and you should therefore start to see this method in upcoming browsers), JavaScript has not historically in ......
第六章 Responsive Interfaces 响应接口
There's nothing more frustrating than clicking something on a web page and having nothing happen. This problem goes back to the origin of transactional web applications and resulted in the now-ubiquitous "please click only once" m ......
第七章 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 ......
Data Formats 数据格式
When considering data transmission techniques, you must take into account several factors: feature set, compatibility, performance, and direction (to or from the server). When considering data formats, the only scale you need for comparison is speed.
......