You Don’t Know JS: Async & Performance

Foreword

Over the years, my employer has trusted me enough to conduct interviews. If we’re looking for someone with skills in JavaScript, my first line of questioning… actually that’s not true, I first check if the candidate needs the bathroom and/or a drink, because comfort is important, but once I’m past the bit about the candidate’s fluid in/out-take, I set about determining if the candidate knows JavaScript, or just jQuery.

Not that there’s anything wrong with jQuery. It lets you do a lot without really knowing JavaScript, and that’s a feature not a bug. But if the job calls for advanced skills in JavaScript performance and maintainability, you need someone who knows how libraries such as jQuery are put together. You need to be able to harness the core of JavaScript the same way they do.

If I want to get a picture of someone’s core JavaScript skill, I’m most interested in what they make of closures (you’ve read that book of this series already, right?) and how to get the most out of asynchronicity, which brings us to this book.

For starters, you’ll be taken through callbacks, the bread and butter of asynchronous programming. Of course, bread and butter does not make for a particularly satisfying meal, but the next course is full of tasty tasty promises!

If you don’t know promises, now is the time to learn. Promises are now the official way to provide async return values in both JavaScript and the DOM. All future async DOM APIs will use them, many already do, so be prepared! At the time of writing, Promises have shipped in most major browsers, with IE shipping soon. Once you’ve finished that, I hope you left room for the next course, Generators.

Generators snuck their way into stable versions of Chrome and Firefox without too much pomp and ceremony, because, frankly, they’re more complicated than they are interesting. Or, that’s what I thought until I saw them combined with promises. There, they become an important tool in readability and maintenance.

For dessert, well, I won’t spoil the surprise, but prepare to gaze into the future of JavaScript! Features that give you more and more control over concurrency and asynchronicity.

Well, I won’t block your enjoyment of the book any longer, on with the show! If you’ve already read part of the book before reading this Foreword, give yourself 10 asynchronous points! You deserve them!

Jake Archibald
jakearchibald.com, @jaffathecake
Developer Advocate at Google Chrome