found drama

get oblique

review: HTML5 and JavaScript Web Apps

by Rob Friesel

HTML5 and JavaScript Web AppsI was drawn to Wesley Hales’ HTML5 and JavaScript Web Apps (O’Reilly, 2012) because it seemed right up my alley — a book about all the latest client-side technologies1 for building enterprise grade “HTML5-based” web apps. At around 150 pages, Hales takes us on a whirlwind tour of these new technologies and tactics, taking a “Mobile First”2 approach and working “up” from there — though he always brings the lessons all the way back around to apps that target mobile devices. Overall, though the style and tone is fairly colloquial, the content is pretty technical, and I would not recommend it to anyone that is not already a competent front-end developer. That being said, if you are that competent front-end developer, then you will find a lot of excellent material here that will introduce and orient you to these new technologies.3

Hales opens the book with a discussion of “modern” client-side architecture, devoting the first four chapters not to specific technologies, but instead to designing loosely coupled “Mobile First” front-ends. As you might have guessed, this means that we spend some time talking about client-side templates;4 about how to approach fluid, “native-feeling” user experiences; and about how to reason about, build, and deploy the front-end piece of your technology stack. Again, as Hales is presenting us with a “Mobile First”5 approach, a lot of attention is given to performance — how to keep components lightweight, how to minimize network overhead, how to design for connectivity interruptions, and how to keep battery consumption down. Overall, it’s a very strong first half — and by itself was worth the price of admission.

The second half of the book is dedicated to the five “HTML5e”6 APIs that Hales calls out as modern, as the place where you can do some real innovation with your app. These five APIs include: WebSockets, Web Storage (e.g., localStorage and sessionStorage), Geolocation, Device Orientation, and Web Workers.7 Without going into detail about each of those APIs here, I will say that Hales introduces each one in an at least serviceable fashion. Each of these chapters describes what that API is; what its target use case is; what the status of its specification is; (approximately) what kind of coverage is out there from the browser vendors; a case study implementation built on top of it; what it takes to shim or polyfill the API (if possible); and what frameworks are out there to support you if you don’t want to “run naked” with that API. Each of these API-centric chapters can stand alone, and you should be able to use any of them as a quick orientation should the need arise. That being said, they vary in their technical depth — e.g., the WebSockets chapter is quite thorough8 while the chapter on Device Orientation seemed to just barely cover the fundamentals.9

All that being said, I did have a couple of quibbles that I need to raise, lest I feel derelict in my duty as a reviewer:

  1. Citation needed. I believe that this book could have used a reference section with citations. There were numerous times where I found myself raising a skeptical eyebrow about some point being made in the text as if it were an unequivocal fact. Example: “CSS selector performance can cripple older mobile browsers.” OK. Says who? Which browsers? What kind of performance hits are we talking about here? “Stats, or it didn’t happen.” It is not that I do not believe him, but I would be more confident if I had more to support the claims that simple trust.
  2. Define your terms. There were a couple of places in the text where I found myself wondering “What do you mean by that?” This was especially true when Hales invoked the phrase “user experience”, which he uses liberally throughout the text without ever really stating what he meant by it. I have an idea of what he means, but I also know that so many people have so many different ideas of what certain terms mean (e.g., “user experience”) that it is seldom safe to assume you know what they mean.
  3. An elephant in the room. There was a big question that never got resolved for me. That was the question of “progressive enhancement”. Hales uses the terms “graceful degradation” and “progressive enhancement” throughout the text, but this is usually in the context of polyfills (which I got the sense he was erroneously conflating with GD/PE). Don’t get me wrong, I appreciate the spirit of Hales’ argument — that you build for the latest/greatest HTML5e technologies, and polyfill your way to your supported bottom. But then in Chapter 4, he is quoting a Yahoo! source which talks about “feature phones” that “can’t even run JavaScript” — and I find myself reflecting on Hales’ opening point from the Preface… The one about client-side templates. And I find myself wondering: What good is all that geolocation and WebSockety goodness if you can’t even render your widgets because JavaScript is turned off?

As I finished the book, I found myself feeling pretty excited about these new “HTML5e” technologies. Hales does a superb job in introducing them and in illustrating the possibilities latent in each one. Even better than that though was his discussion of how to go about designing and developing these modern front-end architectures to begin with. I would definitely recommend this book to front-end developers that have their fundamentals down and are ready to start looking at these kinds of sophisticated APIs and modern architectures.

Disclosure: I received an electronic copy of this book from the publisher in exchange for writing this review.

  1. Well, almost all. There was no WebGL action in there, but it seems kind of ridiculous to think that that would be lumped in there with the “HTML5e” technologies. []
  2. Hales seems to go a step beyond “Mobile First” and (in the Preface) tentatively introduces this notion of “Offline First”. (And/but never really comes back to that little maxim.) []
  3. It’s worth pointing out that Hales is almost painfully aware of how new a lot of these technologies are. Each chapter has an embedded disclaimer of one form or another that indicates the status of the specification (“Working draft!”) and any of the known quirks (“UTF-16 turns 5MB caches into 2.6MB caches!”) or bugs (“JavaScript execution exceeded timeout in iOS after four minutes!”) that exist in the implementations that you’ll encounter out there in the wilds of Userland. It’s almost like he’s handing you a pair of chaps and a ten gallon hat before muttering: “There’s a fortune to be made in these hills if’n you got a strong stomach.” []
  4. Hales says right in the Preface that “if you are convinced that server-side generated markup is the way of the future, then chances are you won’t enjoy this book.” Unfortunately, I think that this statement smells a bit of trolling, and it fails to acknowledge that there’s nuance here. This is a disappointment, because so much of the rest of this book speaks very intelligently about evaluating specific technologies to see how they might solve your problem, and about the choices and trade-offs that you need to make along the way. Where and how your app’s mark-up is generated is another of these considerations, and it was frustrating to see that question cast off so flippantly. (To be totally fair, Hales does later say: “Most of the time, you’ll end up with a hybrid application that does some processing on the server and much more on the client.” Which is a far more sensible thing to say, though considering it’s stated in Chapter 4, it’s almost too-little-too-late.) []
  5. It was somewhere around Chapter 2 that I started to ask myself: Is “Mobile First” just a euphemism for “Modern First”? After all, who are our polyfills and shims really targeting? []
  6. ”HTML5e” is Hales’ shorthand for “HTML5 for Enterprise”. I rather took a shine to that. []
  7. I wrote about Ido Green’s Web Workers book back in July. []
  8. Though I’d argue that he could have provided a little more background on Comet and long-polling, just for the sake of being thorough. []
  9. Perhaps I missed the point? Maybe that really was everything there was to say about Device Orientation? []

About Rob Friesel

Software engineer by day, science fiction writer by night. Author of The PhantomJS Cookbook and a short story in Please Do Not Remove. View all posts by Rob Friesel →

Leave a Reply

Your email address will not be published. Required fields are marked *

*

*