Chapter 9. Unobtrusive JavaScript

In Chapter 2, The Test-Driven Development Process, we saw how test-driven development can help create “clean code that works.” Unfortunately, even perceptibly clean code can cause problems, and on the web there are many degrees of “working.” Unobtrusive JavaScript is a term coined to describe JavaScript applied to websites in a manner that increases user value, stays out of the user’s way, and enhances pages progressively in response to detected support. Unobtrusive JavaScript guides us in our quest for truly clean code; code that either works, or knowingly doesn’t; code that behaves in any environment for any user.

To illustrate the principles of unobtrusive JavaScript, we will review a particularly obtrusive ...

Get Test-Driven JavaScript Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.