Gary Sieling

Book Review: Secrets of the Javascript Ninja

Secrets of the Javascript Ninja,” is a relatively new Javascript book (2013), written by developers with deep browser programming experience, John Resig and Bear Bibeault, It covers lessons learned over many years maintaining Javascript libraries. A lot of the practical guidance is valuable, even if you’re an experienced developer – it includes a lot of notes about common problems developers encounter in browser APIs, many items which are otherwise difficult to learn without hard experience. If you’re primary interest is server-side Javascript, the relevant examples are likely too basic, unless you’re unfamiliar with things like closures.

This is a very practically minded book, with lots of code samples. The book is divided into categories referred to as “Training,” “Apprentice,” “Ninja,” and “Master, ” roughly splitting sections by the complexity and sophistication of material presented. While I find the “Ninja” metaphor goofy, it is not overly pervasive in the book except as a literary prop (note the cover image is a Samurai). The progression of difficulty is consistent with what you might expect from people who work on a library like jQuery: “Master,” for instance, involves patching a browser to handle events and CSS selectors correctly, rather than managing codebases of tens or hundreds of thousands of lines of Javascript code.

For someone who has written a lot of Javascript code, there will be chapters you can skip or skim. I’ve seen some of the material before – having read library documentation, I’ve read numerous discussions of OOP in Javascript, but I found the chapter on Timers invaluable. The authors are big proponents of regular expressions, which I’ve found to be atypical in most code I’ve seen, and thus presents an interesting perspective.

Since the book is relatively new, the authors structure certain chapters around how one might patch useful new constructs into legacy browsers (e.g. event handling improvements), which provides a window into how they think about design, what new features are coming, and how the new features actually work. This isn’t about design patterns per se though, it is about specific APIs that have cause a lot of pain in the past (or currently), and are being improved.

If you’re not currently steeped in browser coding issues, or are only causually, “Secrets of the Javascript Ninja” could easily save you the cost in time through understanding common nuances of brower APIs.

Exit mobile version