第一章 Loading and Execution 加载和运行........................................................................................................ 2 第二章Data Access 数据访问............................................................................................................................ 26 第三章 DOM Scripting DOM编程....................... ............................................................................................. 56 第四章 Algorithms and Flow Control 算法和流程控制.................................................................................. 104 第五章 Strings and Regular Expressions 字符串和正则表达式...................................................................... 139 第六章 Responsive Interfaces 响应接口.......................................................................................................... 184 第七章 Ajax 异步JavaScript和XML ............................................................................................................. 216 第八章 Programming Practices 编程实践........................................................................................................ 261 第九章 Building and Deploying High-Performance JavaScript Applications ..................................................... 279 第十章 Tools 工具............................................................................................................................................ 306 [原版] [译文] 第一章 Loading and Execution 加载和运行 JavaScript performance in the browser is arguably the most important usability issue facing developers. The problem is complex because of the blocking nature of JavaScript, which is to say that nothing else can happen while JavaScript code is being executed. In fact, most browsers use a single process for both user interface (UI) updates and JavaScript execution, so only one can happen at any given moment in time. The longer JavaScript takes to execute, the longer it takes before the browser is free to respond to user input. JavaScript在浏览器中的性能,可认为是开发者所要面对的最重要的可用性问题。此问题因JavaScript 的阻塞特征而复杂,也就是说,当JavaScript运行时其他的事情不能被浏览器处理。事实上,大多数浏览 器使用单进程处理UI更新和JavaScript运行等多个任务,而同一时间只能有一个任务被执行。JavaScript 运行了多长时间,那么在浏览器空闲下来响应用户输入之前的等待时间就有多长。 On a basic level, this means that the very presence of a tag is enough to make the page wait for the script to be parsed and executed. Whether the actual JavaScript code is inline with the tag or included in an external file is irrelevant; the page download and rendering must stop and wait for the script to complete before proceeding. This is a necessary part of the page’s life cycle because the script may cause changes to the page while executing. The typical example is using document.write() in the middle of a page (as often used by advertisements). For example: 从基本层面说,这意味着标签的出现使整个页面因脚本解析、运行而出现等待。不论实际的 JavaScript代码是内联的还是包含在一个不相干的外部文件中,页面下载和解析过程必须停下,等待脚本 完成这些处理,然后才能继续。这是页面生命周期必不可少的部分,因为脚本可能在运行过程中修改页面 内容。典型的例子是document.write()函数,例如 ............................................................................................. 56 第四章 Algorithms and Flow Control 算法和流程控制.................................................................................. 104 第五章 Strings and Regular Expressions 字符串和正则表达式...................................................................... 139 第六章 Responsive Interfaces 响应接口.......................................................................................................... 184 第七章 Ajax 异步JavaScript和XML ............................................................................................................. 216 第八章 Programming Practices 编程实践........................................................................................................ 261 第九章 Building and Deploying High-Performance JavaScript Applications ..................................................... 279 第十章 Tools 工具............................................................................................................................................ 306 [原版] [译文] 第一章 Loading and Execution 加载和运行 JavaScript performance in the browser is arguably the most important usability issue facing developers. The problem is complex because of the blocking nature of JavaScript, which is to say that nothing else can happen while JavaScript code is being executed. In fact, most browsers use a single process for both user interface (UI) updates and JavaScript execution, so only one can happen at any given moment in time. The longer JavaScript takes to execute, the longer it takes before the browser is free to respond to user input. JavaScript在浏览器中的性能,可认为是开发者所要面对的最重要的可用性问题。此问题因JavaScript 的阻塞特征而复杂,也就是说,当JavaScript运行时其他的事情不能被浏览器处理。事实上,大多数浏览 器使用单进程处理UI更新和JavaScript运行等多个任务,而同一时间只能有一个任务被执行。JavaScript 运行了多长时间,那么在浏览器空闲下来响应用户输入之前的等待时间就有多长。 On a basic level, this means that the very presence of a tag is enough to make the page wait for the script to be parsed and executed. Whether the actual JavaScript code is inline with the tag or included in an external file is irrelevant; the page download and rendering must stop and wait for the script to complete before proceeding. This is a necessary part of the page’s life cycle because the script may cause changes to the page while executing. The typical example is using document.write() in the middle of a page (as often used by advertisements). For example: 从基本层面说,这意味着标签的出现使整个页面因脚本解析、运行而出现等待。不论实际的 JavaScript代码是内联的还是包含在一个不相干的外部文件中,页面下载和解析过程必须停下,等待脚本 完成这些处理,然后才能继续。这是页面生命周期必不可少的部分,因为脚本可能在运行过程中修改页面 内容。典型的例子是document.write()函数,例如