High Performance JavaScript - Nicholas C. Zakas

High Performance JavaScript

Nicholas C. Zakas

出版时间

2010-04-02

ISBN

9780596802790

评分

★★★★★
书籍介绍
If you're like most developers, you rely heavily on JavaScript to build interactive and quick-responding web applications. The problem is that all of those lines of JavaScript code can slow down your apps. This book reveals techniques and strategies to help you eliminate performance bottlenecks during development. You'll learn how to improve execution time, downloading, interaction with the DOM, page life cycle, and more. Yahoo! frontend engineer Nicholas C. Zakas and five other JavaScript experts -- Ross Harmes, Julien Lecomte, Steven Levithan, Stoyan Stefanov, and Matt Sweeney -- demonstrate optimal ways to load code onto a page, and offer programming tips to help your JavaScript run as efficiently and quickly as possible. You'll learn the best practices to build and deploy your files to a production environment, and tools that can help you find problems once your site goes live. * Identify problem code and use faster alternatives to accomplish the same task * Improve scripts by learning how JavaScript stores and accesses data * Implement JavaScript code so that it doesn't slow down interaction with the DOM * Use optimization techniques to improve runtime performance * Learn ways to ensure the UI is responsive at all times * Achieve faster client-server communication * Use a build system to minify files, and HTTP compression to deliver them to the browser
AI导读
核心看点
  • 系统讲解JS加载、执行、DOM操作及页面生命周期优化策略
  • 揭示变量访问速度差异,强调局部变量优于全局变量
  • 提供脱离文档流修改DOM、惰性加载等具体性能调优技巧
适合谁读
  • 希望提升Web应用响应速度的前端开发工程师
  • 正在学习JavaScript性能优化最佳实践的开发者
  • 对浏览器渲染机制及JS执行效率感兴趣的技术人员
读前提醒
  • 出版较早,部分浏览器数据已过时,需结合现代环境理解
  • 建议搭配jsperf.com等工具验证书中结论的有效性
  • 翻译版本存在瑕疵,建议对照英文原版阅读关键章节
读者共识
  • 被誉为前端性能优化领域的经典神书,实战价值极高
  • 内容精炼字字如金,虽部分技术过时但核心思想永不过时
  • 适合配合《JS高级程序设计》阅读,深化对语言机制理解

本导读基于书籍简介、目录、原文摘录、短评和书评生成,不等同于全文精读。

精彩摘录
  • "• Literal values and local variables can be accessed very quickly, whereas array items and object members take longer. • Local variables are faster to access than out-of-scope variables because they exist in the first variable object of the scope chain. The further into the scope chain a variable is"
  • "• Minimize DOM access, and try to work as much as possible in JavaScript. • Use local variables to store DOM references you’ll access repeatedly. • Be careful when dealing with HTML collections because they represent the live, underlying document. Cache the collection length into a variable and use "
  • "1. 使元素脱离文档流 2. 对其应用多重改变 3. 把元素带回文档中 有三种基本方法可以使 DOM 脱离文档: - 隐藏元素,应用修改,重新显示 - 使用文档片段(document fragment)在当前 DOM 之外构建一个子树,再把它拷贝回文档 - 将原始元素拷贝到一个脱离文档的节点中,修改副本,完成后再替换原始元素"
  • "一个长度为 n 的数组最终会调用 mergeSort() 2*n-1 次,这意味着一个长度超过 1500 的数组会在 Firefox 上发生栈溢出错误。"
  • "One word of caution: it is not recommended to use this technique for object methods. Many object methods use this to determine the context in which they are being called, and storing a method in a local variable causes this to be bound to window. Changing the value of this leads to programmatic erro"
  • "Firefox, Opera, Chrome, and Safari 3+ all fire a load event when the src of a <script> element has been retrieved. You can therefore be notified when the script is ready by listening for this event:"
  • "If you only care about sending data to the server (with possibly a very simple response), use image beacons. Beacons are the fastest and most efficient way to send data back to the server. The server doesn’t have to send back any response body at all, so you don’t have to worry about downloading dat"
  • "These two functions implement a lazy-loading pattern. The first time either method is called, a check is made to determine the appropriate way to attach or detach the event handler. Then, the original function is overwritten with a new function that contains just the appropriate course of action. Th"
用户评论
必备基础
小脚本,大世界
现在是2013年,刚花了几个小时把这本书通读了一遍。书很薄,内容很直白,读起来飞快。可以想像就2010年的时间点来说这本书里很多建议挺靠谱的。但如果它今天再版的话,很多内容恐怕都要修正了,特别是关于JavaScript核心语言性能的部分。而且总觉得这书有些细节上技术术语用词不准确⋯不过不影响大的主题,问题不大。
这是看过的最好的javascript的书,没有之一。Chapter2: Data access最重要。
JS本身的执行效率没什么好担心的. 前端性能优化还是 Steve Souders 的两本书更有价值. 而这些最佳实践也都已经充分传播开来了.
读完了,虽然文章末的工具已经很老了,不过整体上来说绝绝子。 作者对每个概念进行内存和性能方面的分析的图表令人印象深刻,且讲解鞭辟入里,案例也很棒,赞👍🏻
搭配 jsperf.com 服用。F2E 居家必备。
很棒的书,但因为比较久了,里面大部分内容已经不再适用了。
即使从 分析 角度来说,也是好书。Analysing &amp; profiling: algorithms, language statements, DOM, render, I/O, parallels, cache, regex &amp; XML etc.
5年里JS界早换了模样 还是涨了一些姿势
收藏