This hands-on book looks past the hype and buzzwords surrounding HTML5 and gives you a conservative and practical approach to using HTML5, JavaScript MVC frameworks, and the latest W3C specifications. You’ll quickly master how to build mobile and desktop web apps that are widely supported across all major web browsers and devices.
Even though Web Storage, Web Workers, Geolocation, Device Orientation, and WebSockets have been covered many times in the past, it is often from a very high or basic level. This book goes into the trenches to review actual use cases for each of these APIs and gives real-world examples on how to use each one. If you're familiar with JavaScript, CSS and HTML basics and are ready to start piecing together the architecture of HTML5, then this book is for you.
Assemble a coherent architectural whole from HTML5’s complex collection of partsGain a clear understanding of client-side architecture and the "mobile first" approachDesign, create, and tune eye-catching and robust mobile web appsExplore how the top five JavaScript MVC frameworks interact with the serverLearn best practices for setting up a raw WebSocket serverExamine how sites such as Google, Twitter, and Amazon store data on the clientUse real-world methods for applying geolocation, and learn the pitfalls of various implementationsProcess images and other data in the background with Web Workers
I 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 technologies [1] 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 bringing 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. 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 thorough [7] while the chapter on Device Orientation seemed to just barely cover the fundamentals. [8]
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." 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 used the phrase "user experience", which he uses liberally throughout the text without ever really stating what he means 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 it means that it is seldom safe to assume you know what they mean. 3. An elephant in the room. There seemed was a big question that never seemed to get 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 that point that Hales more/less opens with... 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.
----
[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]: 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.
[8]: Perhaps I missed the point? Maybe that really was everything there was to say about Device Orientation?
---
(Disclosure: I received an electronic copy of this book in exchange for writing a review.)
One of the factors facing anyone who wants to develop a web site or a mobile web application today is that the world of server-side scripting for functionality is (has?) giving way to much more dynamic applications with the client doing most of the heavy lifting. JavaScript has moved beyond being a little bit of glue code or a few dispersed libraries that added some special effects or eye candy to a site. Now, applications are being developed and generated by JavaScript libraries and frameworks to the point where static HTML may be slim to nonexistent.
The goal today is less a matter of control via the server and being open to creating applications that are performant, scalable, and utilize the latest Web infrastructure and application features. We are reaching a point where, for many, the mobile web is the way that they interact with the Internet (lugging around a laptop like me for much of the day is starting to look a bit old school ;) ).
"HTML5 and JavaScript Web Apps" by Wesley Hales is a survey of the emerging and solidifying standards that are defining the landscape of what web and mobile apps will look like in the near future. Yes, the emphasis here is mobile, though there are also several sections devoted to traditional web sites and applications. This books is, as I mentioned, a "survey"; it does not go in depth on any of the technologies. What it does provide is a lot of examples and ideas to spur thought, and an invitation to go and explore what's out there.
If you are a new web developer, or have not already spent significant time playing with front end development practices, this is not going to get you there. That's OK, though, it's not meant to. If you are a software tester who would like to have a handy reference, and some context, as to what these features are and how they work, at 156 pages, it makes for a handy "cheat sheet" and jump off.
Several approaches to how the web developer can improve performance and user experience are mentioned, including tools that help with compression, web sockets, utilizing Web Storage, and the variety of JS frameworks that are currently in play (node, angular, backbone, ember, batman, and knockout get specific mention and coverage).
While the book's title talks about being about HTML5 and JavaScript Web apps, a more appropriate title would be "The Emerging HTML5e Standards and the Options it Provides, Coupled with Several JavaScript Framework Engines and Additional Utilities to Help Design for Both Mobile and Traditional Web"… but that would be really long ;).
So if this book for you? If you are looking for a quick survey, with some supporting information of the various "cool new bits" to play with, and you don't mind a lack of detail or depth, then yes, this book fits that role rather handily. Testers, if you want to get an overview of what a lot of these technologies actually do, and how to recognize them in the wild, then yes, this book is worthwhile, and even more so in eBook format, since the links jump you to other resources. If you are looking for an in-depth book that will give you practical hands on experience and exercises to work through to learn these technologies, then no, this book would be wholly inappropriate for that purpose.