JavaScript Framework Design cover

JavaScript Framework Design

Rating 3.8
Word count
528 words
Chapters
16
ISBN
9787115343583

Tags

Summary

This book is a monograph on JavaScript framework design by Situ Zhengmei (Zhong Qincheng), systematically laying out "how to build a front-end framework from scratch." The book follows the framework's skeleton as its main thread: first the seed module (namespaces, object extension, array conversion, type detection, domReady, no-conflict handling), then the module loading system (the AMD specification and the implementation of require/define), followed by the language module's extensions and fixes for strings, arrays, numbers, functions, and dates. The middle section moves into how a framework deals with the browser: browser sniffing and feature detection, style-support detection, class factories and JavaScript inheritance implementations, selector engines and node modules, data caching systems, style modules, and attribute modules (including an analysis of jQuery's attribute system). The latter half focuses on behavior and interaction: the event system, asynchronous processing and Ajax data-interaction modules, the animation engine, API design and plug-in architecture, and finally an introduction to mainstream MVVM frameworks, monitored arrays, and sub-templates. Throughout, the book emphasizes the path of "read the source—replicate it—abstract it," with numerous examples directly compared against the implementation ideas of mature libraries such as jQuery. It is written for front-end developers who want to understand the underlying principles of frameworks rather than settle for merely calling APIs.

Editor's review

市面上的前端书大多教你怎么用框架,这本教你怎么造框架。作者司徒正美是 avalon(迷你 MVVM 框架)的作者,书里的每一章几乎都对应他自己走过的一条坑路:种子模块怎么起、模块加载怎么设计、选择器引擎怎么写、事件系统怎么兼容老浏览器、动画和 Ajax 怎么封出好用的 API。它的写法偏“源码解剖”——把 jQuery 等成熟库的实现摊开给你看,再讲清为什么这么设计,这种颗粒度在中文前端书里并不多见。需要提醒的是:本书成书于 2014 年,讨论的浏览器兼容、DOM API 与 jQuery 生态有鲜明的时代印记,MVVM 部分也主要围绕当时的框架展开,因此它更适合当作“框架原理地图”来读,而不是当作现代前端工程实践手册。想真正读懂,最好边读边敲代码,把每章的小模块自己实现一遍。

Who it's for

A good fit for

  • 已经能用 jQuery 或 Vue 写业务,想弄懂框架内部原理的前端工程师
  • 准备自研或维护公司内部组件库、小型框架的开发人员
  • 计算机相关专业想从源码层面理解 JavaScript 与 DOM 封装的学生
  • 需要评估选型、与框架作者对话的项目负责人和技术管理者

Not a good fit for

  • 完全没有 JavaScript 与 DOM 基础的纯入门读者
  • 只想学 Vue/React 用法、做业务落地的读者
  • 期待现代构建工具、TypeScript 与工程化方案的系统讲解者

Reading tips

  1. 先通读第1—3章,亲手实现种子模块和语言模块,建立“框架是一堆小积木”的直觉。
  2. 读书时随手翻对应库的源码(jQuery、avalon)对照,书中的结论要用代码验证一遍。
  3. 把书中 2014 年前后的兼容方案当作历史背景,结合现代浏览器与 ES6+ 标准重新思考取舍。
  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 The Seed Module (Namespaces, Object Extension, Array Conversion, Type Detection, domReady, No-Conflict Handling)
  2. Chapter 2 The Module Loading System (AMD Specification, Loader Path Detection, the require Method, the define Method)
  3. Chapter 3 The Language Module (Extensions and Fixes for Strings, Arrays, Numbers, Functions, and Dates)
  4. Chapter 4 Browser Sniffing and Feature Detection (Identifying Browsers, Event-Support Detection, Style-Support Detection, the Meaning of jQuery's Common Features)
  5. Chapter 5 Class Factories (JavaScript's Support for Classes, Implementations of Various Class Factories: P.js, JS.Class, simple-inheritance, etc.)
  6. Chapter 6 The Selector Engine
  7. Chapter 7 The Node Module
  8. Chapter 8 The Data Caching System
  9. Chapter 9 The Style Module
  10. Chapter 10 The Attribute Module (Including jQuery's Attribute System)
  11. Chapter 11 The Event System
  12. Chapter 12 Asynchronous Processing
  13. Chapter 13 The Data-Interaction Module (A Complete Ajax Implementation)
  14. Chapter 14 The Animation Engine
  15. Chapter 15 API Design and Plug-In Architecture
  16. Chapter 16 An Introduction to Mainstream MVVM Frameworks, Monitored Arrays, and Sub-Templates

FAQ

这本书和它的第2版有什么区别?
第1版 2014 年出版,ISBN 9787115343583,约 437 页、528 千字;第2版 2017 年出版(ISBN 9787115464293),扩充到 457 页、约 516 千字,重组了章节,增加了 MVVM 动态模板、性能墙与复杂墙、组件方案(jQuery、avalon2、React)等内容。想读较新内容请选第2版。
没有框架使用经验能读吗?
勉强能读,但会很吃力。书中大量类比 jQuery 的实现,若完全没用过 jQuery、不了解 DOM 操作与事件模型,建议先补基础再回来看,否则容易停留在“看得懂字、串不起逻辑”的状态。
书里的技术是否已经过时?
部分内容确实带有时代烙印,比如旧版 IE 的浏览器嗅探与兼容性处理、以 jQuery 为参照的实现思路。但模块化拆分、事件系统设计、异步模型、模板与组件抽象这些方法论层面仍然有参考价值,读时应带着批判和迁移的眼光。
作者司徒正美是谁?
本名钟钦成,网名司徒正美,知名 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