JavaScript Framework Design (2nd Edition) cover

JavaScript Framework Design (2nd Edition)

Rating 3.5
Word count
516K words
Chapters
16
ISBN
9787115464293

Tags

Summary

This book is the second edition of JavaScript Framework Design, written by the well-known front-end developer Situ Zhengmei (Zhong Qincheng) for intermediate and advanced front-end readers who want to understand why frameworks are written the way they are. The book consists of 16 chapters and follows the evolution of the author's own frameworks, mass Framework and avalon, as its main thread. It begins with the most fundamental seed module: modular organization, object extension, array conversion, type detection, domReady, and no-conflict handling. Next comes the language module, which extends and applies compatibility fixes to native methods for strings, arrays, numbers, functions, dates, and more. The middle section moves into the dirtiest and most labor-intensive part of framework design: browser sniffing and feature detection, class factories and property descriptors, the selector engine and the implementation ideas behind Sizzle, the node module (creation, insertion, cloning, removal, and innerHTML-series compatibility handling), the multi-generational evolution of the data caching module, the style module's handling of opacity, the box model, dimensions, and coordinates, and the attributes module's distinction between intrinsic and custom attributes. The event system is covered in two chapters, one for desktop and one for mobile, sorting out the flaws of attachEvent and addEventListener along with event delegation and simulated implementations. The latter half of the book discusses asynchronous models (callbacks, Promise, generators, async/await), the data interaction module (from XMLHttpRequest to fetch), the animation engine (easing formulas, requestAnimationFrame, CSS3 transition/animation), and goes deep into MVVM and componentization: static and dynamic templates, evaluation functions and refresh functions, Proxy/Reflect, virtual DOM and the diff algorithm, the performance wall and the complexity wall, and finally a comparison of three component solutions—jQuery, avalon2, and React—as well as front-end routing.

Editor's review

市面上的前端书大多教你怎么“用”框架,这本书讲的是怎么“造”框架。司徒正美把自己多年写 mass Framework、avalon 的经验一层层摊开:为什么要有种子模块,为什么类型判定要写得那么啰嗦,为什么选择器引擎要拆成切割器和匹配器,为什么 jQuery 的数据缓存要改三代。这些内容在官方文档和 API 手册里永远看不到,却正是把“会写业务”和“懂框架”区分开的东西。 第2版相较2014年初版做了大幅增补:事件系统拆成 PC 端与移动端两章,异步模型补进 Promise、生成器与 async 函数,数据交互一路写到 fetch,MVVM 与组件部分则新增了虚拟 DOM、diff 算法、Proxy/Reflect,并把 jQuery 时代的组件方案、avalon2 的 slot 机制、React 的生命周期放在一起对照。读起来难免有点“考古”味道——大量篇幅在和 IE 的怪癖搏斗,今天的项目很少还需要这些补丁;但恰恰是这些补丁,把浏览器 API 的历史断层和兼容层的设计权衡讲得最透。若你已经能熟练写 React/Vue 组件,却说不清响应式、diff、事件代理背后的取舍,这本书会很对胃口。

Who it's for

A good fit for

  • 有 1—3 年经验、想从“会用框架”进阶到“看懂框架源码”的前端工程师
  • 准备造轮子、写公司内部组件库或微前端底座的技术骨干
  • 需要维护老项目、处理浏览器兼容与事件/样式差异的开发者
  • 计算机相关专业的高年级学生,想补一堂体系化的前端框架原理课

Not a good fit for

  • 零基础编程初学者,书里默认你熟悉 DOM 与原生 API
  • 只想快速学会 React/Vue 用法做业务、不关心底层实现的读者
  • 对浏览器兼容史和源码级细节没有耐心的速成型读者

Reading tips

  1. 先通读第1—3章打底,再按需挑章精读,不必从第4章一路啃到第16章。
  2. 每章都配着源码读:把书中的简化实现敲进本地 demo,跑通再改一个功能,收获远大于只看。
  3. 兼容性章节可结合现代浏览器实测对照,重点理解权衡思路,不必照搬针对 IE 的写法。
  4. 读 MVVM 与组件两章时,同步打开 React 或 avalon 源码,对照 diff、生命周期与前端路由的实现。
  5. 书中部分内容成书于 2017 年前后,涉及具体框架 API 的地方请以现在的官方文档为准。

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
  2. Chapter 2 Language Module
  3. Chapter 3 Browser Sniffing and Feature Detection
  4. Chapter 4 Class Factory
  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 The PC Event System
  11. Chapter 11 The Mobile Event System
  12. Chapter 12 Asynchronous Models
  13. Chapter 13 Data Interaction Module
  14. Chapter 14 Animation Engine
  15. Chapter 15 MVVM
  16. Chapter 16 Components

FAQ

第2版和第1版有什么区别?
第1版2014年出版,约437页、528千字,豆瓣评分7.6。第2版2017年出版,457页、约516千字,ISBN为9787115464293。第2版把事件系统拆成PC端与移动端两章,补充了Promise等异步模型、fetch、虚拟DOM与diff算法、Proxy/Reflect、avalon2的slot机制以及React组件方案,章节由原来的结构扩展为16章。
这本书适合零基础学前端的人吗?
不太适合。书中大量内容建立在DOM操作、事件模型、原型继承等基础上,默认读者已能独立完成前端开发,更多是给想读懂框架原理、准备自研组件库的中高级开发者阅读。零基础建议先补原生JavaScript与浏览器API。
书里的内容现在是不是过时了?
书中有相当篇幅在与IE的兼容性问题搏斗,其中一些写法在今天已不需要。但框架设计的核心议题——模块组织、选择器、缓存、事件代理、异步模型、响应式与虚拟DOM——依然是理解现代框架的关键,作为思路与历史参考仍然有价值。
作者是谁?有什么背景?
作者本名钟钦成,网名司徒正美,是国内前端社区知名的JavaScript开发者,长期维护自研框架mass Framework与MVVM框架avalon,并参与前端类库与工具的建设。本书正是他多年框架实践的系统总结。
需要配合哪些前置知识来读?
建议先熟悉ES5/ES6语法、原型与闭包、DOM节点操作、事件冒泡与捕获、XMLHttpRequest等基础;了解jQuery的常见API会更容易理解书中的对照分析。若完全没接触过Promise与async,可先补异步编程基础再看第12章。

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