Maintainable JavaScript – Writing Code Others Can Read and Support – #programming #bookreview

Maintainable JavaScript
Nicholas C. Zakas
(O’Reilly, paperback, list price $34.99; Kindle edition, list price $27.99)

If you work with JavaScript – alone or in a development group – or if you are still learning JavaScript, you need this book.

Three reasons why:

  • If you have learned JavaScript on your own, hoping to land a job with a big company, you likely have developed your own style of coding.
  • If you are just starting to learn JavaScript, you don’t have a coding style yet. But you are fresh meat for creating your own in the near future.
  • If you have recently started working as part of a software development team, you likely have just made a rather painful discovery. Your carefully honed own coding style is not acceptable for the work you have just been assigned. Very quickly you must adapt to new coding conventions (or style guidelines) enforced by your manager.

Maintainable JavaScript focuses on the importance of following strict style guidelines and creating code that others in a development team can easily understand, maintain, adapt and extend.

The author, Nicholas C. Zakas, has written two previous JavaScript books. His latest is drawn from best practices he observed, followed, and developed at Yahoo! over five years while he was front-end tech lead for Yahoo!’s homepage, as well as a contributor to the YUI library.

“When a team is brought together for the first time, everyone brings with them their own ideas about how code should be written, “ Zakas notes. “After all, each team member comes from a different background.” And: “Everyone has an opinion about how code should be written, and it usually falls in line with how that individual would personally write it. Establishing style guidelines should always come as early in the process as possible.”

His well-written 219-page book is organized into three parts and 20 chapters.

In the Style Guidelines part, the chapters are:

  • Basic Formatting
  • Comments
  • Statements and Expressions
  • Variables, Functions, and Operators

The Programming Practices part has these chapters:

  • Loose Coupling of UI Layers
  • Avoid Globals
  • Event Handling
  • Avoid Null Comparisons
  • Separate Configuration Data from Code
  • Throw Your Own Errors
  • Don’t Modify Objects You Don’t Own
  • Browser Detection

And the Automation part has the following chapters:

  • File and Directory Structure
  • Ant
  • Validation
  • Concatenation and Baking
  • Minification and Compression
  • Documentation
  • Automated Testing
  • Putting It Together

The book’s two appendices are “JavaScript Style Guide” and “JavaScript Tools.”

Maintainable JavaScript smoothly and cleanly covers a lot of important ground. It takes you from the often-debated guidelines for indentation — “indentation is about as close to religion as software engineers get,” Zakas says — to enduring the “pain point” of browser testing, and creating build directories for development, integration, and release builds.

Si Dunn


  • Si Dunn is a novelist, screenwriter, photojournalist, and book reviewer. His published books include: DARK SIGNALS, a Vietnam War memoir; ERWIN'S LAW, a private-detective novel; and JUMP, a novella about a combat veteran suffering from PTSD and alienation while trying to work for newspapers as a journalist. Several of his feature screenplays recently were under option to movie producers. He spent nearly 15 years working as a technical writer and software tester in the telecommunications industry. His current programming interests include Go, JavaScript, Python, R, Angular, and other languages and frameworks. He is a U.S. Navy veteran and a graduate of the University of North Texas.

Leave a Reply

%d bloggers like this: