JavaScript Framework Design (2nd Edition) cover

JavaScript Framework Design (2nd Edition)

Rating 3.5
Word count
516 words
Chapters
16
ISBN
9787115464293

Tags

Summary

JavaScript Framework Design is an original technical work built on the long accumulated experience of front-end developer Zhengmei Situ (Qincheng Zhong). The second edition revises and expands on the first, centering on "how to build a JavaScript framework from scratch" and dismantling layer by layer the invisible foundations inside front-end frameworks. The book has sixteen chapters: starting from the seed module, it discusses modular organization, object extension, array-like conversion, type detection, domReady, and no-conflict handling; then the language module, demonstrating extensions and capability fixes for native types such as strings, arrays, numbers, functions, and dates; next come browser sniffing and feature detection, class factories and various inheritance schemes, selector engines, the node module, the data cache module, the style module, and the attribute module, taking apart the core subsystems of the jQuery era one by one. The event system section covers both desktop and mobile events and specifically analyzes jQuery's event system; the asynchronous model chapter extends to Promises and later async approaches; the data interaction module provides a complete Ajax implementation; animation engines, API design, and pluginization relate to a framework's usability and extensibility. The later sections move into MVVM: static front-end templates, MVVM dynamic templates, the performance wall and complexity wall, and component solutions, with a horizontal comparison of jQuery-era components, avalon2 components, and React components. The first edition was published in 2014 and the second revised in 2017; with three years between them, readers can compare chapter differences across editions.

Editor's review

市面上讲“怎么用框架”的书多到泛滥,讲“框架为什么这么写”的书却始终稀缺,这本是少数之一。它的价值不在教你调用 API,而在把 jQuery、avalon 这类框架的内部零件一个个拆开摆在你面前:domReady 到底怎么判断、选择器引擎怎么从字符串变成元素、类工厂为什么要绕那么多弯、事件系统怎样做冒泡与委托、模板怎样从静态字符串变成可更新的 DOM。作者司徒正美本人就是 avalon 框架的作者,写的是自己淌过的坑,所以细节密度高、判断有立场,读到“这里为什么要这样设计”时往往能给出取舍理由,而不是转述文档。第2版新增了移动端事件、React 组件方案与性能墙等内容,把 jQuery 时代与 MVVM 时代串成一条线,读者能看清前端框架三十年(编者按:实为二十余年)演化中哪些问题始终没变。需要提醒的是,本书示例大量基于 ES5 时代的写法与作者的 avalon 体系,对只写 React/Vue 业务代码、且不熟悉原型链与兼容性处理的读者会有门槛;把它当作“读懂老框架源码”的钥匙,体验最好。

Who it's for

A good fit for

  • 有一到三年经验、想弄清框架底层实现的前端开发者
  • 需要维护或二次开发 jQuery 类老项目的工程师
  • 准备面试、想系统补足 JavaScript 语言与 DOM 底层知识的人
  • 计算机相关专业高年级学生与培训机构的进阶课程学员
  • 对框架设计方法论感兴趣、打算自研内部组件库的技术负责人

Not a good fit for

  • 零基础读者:书中默认你熟悉 JavaScript 语法与 DOM 操作
  • 只想学 React 或 Vue 业务写法、不关心实现原理的人
  • 期望全书基于 ES6+ 与 TypeScript 现代语法的读者,本书示例仍以 ES5 为主

Reading tips

  1. 按章节顺序读前三章打底,之后再按兴趣跳读选择器、事件、模板等重点章节,不必逐页死磕。
  2. 读每个模块时打开对应开源框架源码对照,边读边在控制台复现作者的最小实现。
  3. 第2版与第1版章节差异较大,若两版都在手,先读第2版的移动端事件与组件章节。
  4. 遇到兼容性代码不必逐条记忆,重点理解“为什么要做特征侦测”这一层设计思路。

About the publisher

Posts & Telecom Press China · Founded in 1953

Posts & Telecom Press is known for its strengths in science and technology, computing, and information and communications titles, and has extended its publishing into photography, art, software learning, and inspirational growth, giving it a fairly diverse range. Its catalog includes computing and communications works such as Refactoring and Patterns (Revised Edition) and Huawei Switch Learning Guide (Second Edition), alongside bilingual collector's editions such as The Little Prince (Chinese-English-French illustrated collector's edition), The Great Gatsby, and Three Days to See. Beijing Ten Years: 1980-1990 and Ghost Blade: WLOP Personal Illustration Collection reflect its presence in photography and art. Its authors include Antoine de Saint-Exupéry, Helen Keller, Joshua Kerievsky, Wang Da, Zhang Zhaozeng, and WLOP.

Contents

  1. Chapter 1 Seed Module (modularization, feature introduction, object extension, array-like conversion, type detection, domReady, no-conflict handling, summary)
  2. Chapter 2 Language Module (string extensions and fixes: repeat, byteLen, pad, quote, trim and whitespace; extensions and fixes for arrays, numbers, functions, dates)
  3. Chapter 3 Browser Sniffing and Feature Detection (browser detection, the document.all anecdote, event support detection, style support detection, meanings of common jQuery features)
  4. Chapter 4 Class Factories (JavaScript's support for classes, implementations of various class factories: P.js, JS.Class, simple-inheritance, def, etc.)
  5. Chapter 5 Selector Engine
  6. Chapter 6 Node Module
  7. Chapter 7 Data Cache Module
  8. Chapter 8 Style Module
  9. Chapter 9 Attribute Module
  10. Chapter 10 Event System (desktop and mobile events, jQuery's event system)
  11. Chapter 11 Asynchronous Model
  12. Chapter 12 Data Interaction Module (a complete Ajax implementation)
  13. Chapter 13 Animation Engine
  14. Chapter 14 MVVM and Front-End Templates (static templates, MVVM dynamic templates)
  15. Chapter 15 Performance Wall and Complexity Wall, Components (jQuery-era component solutions, avalon2 component solutions, React component solutions)
  16. Chapter 16 API Design, Pluginization, and Framework Outlook

FAQ

这本书和《JavaScript高级程序设计》有什么区别?
《高级程序设计》讲语言与浏览器 API 的全面用法,属于“学会用”;本书讲框架内部如何组织这些能力,属于“学会造”。建议先用前者打基础,再用本书进阶。
第1版和第2版应该买哪一版?
第2版(ISBN 9787115464293,2017 年,457 页)内容更完整,新增移动端事件、React 组件方案、性能墙等章节,建议优先选第 2 版;第 1 版为 2014 年 437 页版本。
书里的技术是不是已经过时了?
示例确实以 ES5 与 jQuery 时代写法为主,但模块化、事件模型、模板编译、组件化这些问题的设计思路并不过时,读懂老框架反而更容易看清现代框架在解决什么。
需要先读完 jQuery 源码吗?
不需要。书中会给出关键片段与作者自己的实现,先具备 JavaScript 原型、闭包、DOM 事件的基本功即可跟上大部分章节。
作者司徒正美是谁?
本名钟钦成,国内知名 JavaScript 专家,MVVM 框架 avalon 的作者,长期在前端框架与组件化方向做实践与分享,本书是其代表作。

Comments

Find this book

This site is an index: you start “Search all sources” in your browser, and the entries it lists all point to third-party sites; please judge their availability yourself.

About the author

司徒正美 Author

Situ Zhengmei is a technical author in the field of front-end development in China. Publicly available information about the author is limited, and the best-known representative work is JavaScript Framework Design (2nd Edition). This book falls under programming design and focuses on the design ideas and implementation methods of JavaScript frameworks, targeting learners and developers who want to understand the underlying mechanisms of front-end frameworks in depth. In terms of subject matter, the author attends to abstraction and engineering practice at the framework level rather than listing scattered syntax tips, and the writing tends to move from design principles to code implementation, helping readers build an overall understanding of framework structure. Because only one work by this author is included in the collection, details such as biography and professional experience cannot be verified; readers may turn to the book itself to learn about the author's technical grounding and expressive style in JavaScript framework design.

More by the same author

Top rated in the same category