Last Updated: February 25, 2016
·
725
· webpro

Book Review: Async JavaScript

Overview

The book is a pleasant read, and the author (Trevor Burnham) knows what he is writing about. The topic is very specific, but essential knowledge for the target audience (intermediate JavaScripters) that want to improve their knowledge and understanding of the language. It's 183 pages (in iBooks) and the topic is covered quite well. After reading the book, the reader should have a decent understanding of async JavaScript, common related patterns, and how to solve common issues when dealing with the subject.

I especially liked the sections "Flow control with Async.js" and "Async script loading".

However, the book is not perfect. It's definitely worth the investment (only $11 for the eBook), but I do have some critical notes. These are covered below.

The first chapter

The first chapter is using the concept of events to explain asynchronicity in JavaScript. It's using the setTimeout function to do so. Which is fine, but the first example is a bit too complicated if you'd ask me, since it is dealing with more concepts than it needs to to explain in the very first paragraphs (e.g. scope, threads).

While the categorisation of async functions (I/O and timing) is very useful, I was surprised that user events (I/O) was mentioned only very briefly here.

At the end of each chapter is a "What we've learned" section. For the first chapter, this is mentioning:

we've seen how JavaScript's single-threadedness is both a blessing and a curse

While that's true, the other 90% of the section is about "the rest of this book". Guess a bullet list of topics covered would be more appropriate, especially in the first chapter. Also in other chapters this section has more content covering what the author wants the reader to know about the topic, not just a list of what was actually covered in the chapter.

Overall, the first chapter feels a bit disorganised.

jQuery

For the topics of distributed events (PubSub), custom events, and Promises, the author is using jQuery extensively. While there's nothing wrong with using a library to explain and demonstrate concepts, it does carry the risk of readers turning to this library just for one feature (e.g. PubSub or Promises).

PubSub

jQuery is mentioned so much in the "distributed events" chapter, that the reader probably doesn't realise that jQuery's PubSub is DOM-based (afaic) and like-wise, the chapter deals with UI events only (except a bit about Backbone Model events). The publish/subscribe pattern itself isn't getting at all the attention it deserves.

Deferreds

While jQuery Deferreds has issues on its own - which aren't mentioned - the chapter about Promises also notes that jQuery can be used in Node. There's a lot of questionable advice here. This chapter is written totally from a jQuery perspective, like in this chapter's "What we've learned":

In my opinion, Promises are one of the most exciting features to be added to jQuery in years.

While I actually agree with the statement, I think what matters is that the concept of Promises was introduced in JavaScript (not by jQuery, btw).

In summary, the book is about async JavaScript, but those topics are written as "let's turn to jQuery for everything".

Final words

While I have written down some some negative feedback here, I still do happily recommend the book. It's a great read for intermediate JavaScripters aiming to enhance their knowledge in this area of the language.