small medium large xlarge

Async JavaScript: Build More Responsive Apps with Less Code


Cover image for Async JavaScript

Async JavaScript

Build More Responsive Apps with Less Code


With the advent of HTML5, front-end MVC, and Node.js, JavaScript is ubiquitous—and still messy. This book will give you a solid foundation for managing async tasks without losing your sanity in a tangle of callbacks. It’s a fast-paced guide to the most essential techniques for dealing with async behavior, including PubSub, evented models, and Promises. With these tricks up your sleeve, you’ll be better prepared to manage the complexity of large web apps and deliver responsive code.

Async JavaScript was previously self-published. It’s been completely edited and revised since its initial publication and is now part of our Pragmatic exPress series.

Customer Reviews

Async JavaScript is the first full book I’ve seen dedicated to a key topic in Java-
Script development today: how to deal with concurrency and concurrent tasks
without going crazy! For the sake of your sanity, check this out.

- Peter Cooper

editor, JavaScript Weekly

Trevor delivers a concise guide to writing asynchronous JavaScript with a perfect
balance of browser and server-side examples. Part guide, part overview, wholly
engaging, this book is a must-read for any JavaScript developer looking to level

- Wynn Netherland

co-host, The Changelog

This is a complete guide to the asynchronous realm of JavaScript. The concepts
and tools covered by this book are essential to anyone willing to build full-blown,
well-structured and efficient JavaScript applications.

- Julien Biezemans

Ruby/JavaScript developer, author of Cucumber.js

Run—–don’t walk—–to your computer, and order Trevor Burnham’s Async Java-
Script immediately. It’s an essential manual for programmers working with both
in-browser and Node-based JavaScript. In addition to introducing and demystifying
JavaScript’s event model, Async JavaScript is a practical manual for writing efficient
and readable asynchronous code. I recommend it.

- Reginald Braithwaite

author of CoffeeScript Ristretto

I only have two JS books that I keep on my desk for daily reference: the Rhino
book and the Good Parts. Trevor’s book will be the third.

- Lon Ingram

lead front-end developer for Waterfall

Trevor’s passion for JavaScript again provides us with a useful book. In these
times of growing JavaScript use cases and complexity, with server runtimes and
ever-growing client-side apps, mastering async patterns is essential to keeping
our codebases maintainable, even elegant. This book delivers a large number of
precious tips, techniques and technical pointers to achieve that almost effortlessly.
Well done, Trevor!

- Christophe Porteneuve

CTO, Delicious Insights

See All Reviews

Choose Your Format(s)

  • $11.00 In Stock
  • Ebooks are DRM free.

  • Ebook delivery options.

About this Title

Pages: 104
Published: 2012-11-28
Release: P2.0 (2014-07-30)
ISBN: 978-1-93778-527-7

With Async JavaScript, you’ll develop a deeper understanding of the JavaScript language. You’ll start with a ground-up primer on the JavaScript event model—key to avoiding many of the most common mistakes JavaScripters make. From there you’ll see tools and design patterns for turning that conceptual understanding into practical code.

The concepts in the book are illustrated with runnable examples drawn from both the browser and the Node.js server framework, incorporating complementary libraries including jQuery, Backbone.js, and Async.js. You’ll learn how to create dynamic web pages and highly concurrent servers by mastering the art of distributing events to where they need to be handled, rather than nesting callbacks within callbacks within callbacks.

Async JavaScript will get you up and running with real web development quickly. By the time you’ve finished the Promises chapter, you’ll be parallelizing Ajax requests or running animations in sequence. By the end of the book, you’ll even know how to leverage Web Workers and AMD for JavaScript applications with cutting-edge performance. Most importantly, you’ll have the knowledge you need to write async code with confidence.

What You Need:

Basic knowledge of JavaScript is recommended. If you feel that you’re not up to speed, see the “Resources for Learning JavaScript” section in the preface.

Contents & Extracts

  • Acknowledgments
  • Introduction
    • Trouble in Paradise
    • Who Is This Book For?
    • Resources for Learning JavaScript
    • Where to Turn for Help?
    • Running the Code Examples
    • Code Style in This Book
    • A Word on altJS
    • Resources for This Book
  • Understanding JavaScript Events
    • Scheduling Events
    • Types of Async Functions
    • Writing Async Functions
    • Handling Async Errors
    • Un-nesting Callbacks
    • What We’ve Learned
  • Distributing Events
    • PubSub
    • Evented Models
    • Custom jQuery Events
    • What We’ve Learned
  • Promises and Deferreds excerpt
    • A Very Brief History of Promises
    • Making Promises
    • Passing Data to Callbacks
    • Progress Notifications
    • Combining Promises
    • Binding to the Future with pipe
    • jQuery vs. Promises/A
    • Replacing Callbacks with Promises
    • What We’ve Learned
  • Flow Control with Async.js
    • The Async Ordering Problem
    • Async Collection Methods
    • Organizing Tasks with Async.js
    • Dynamic Async Queuing
    • Minimalist Flow Control with Step
    • What We’ve Learned
  • Multithreading with Workers excerpt
    • Web Workers
    • Node Workers with cluster
    • What We’ve Learned
  • Async Script Loading
    • Limitations and Caveats
    • Reintroducing the <script> Tag
    • Programmatic Loading
    • What We’ve Learned
  • Tools for Taming JavaScript
    • TameJS
    • StratifiedJS
    • Kaffeine
    • Streamline.js
    • Node-Fibers
    • The Future of JavaScript: Generators


Trevor Burnham is a JavaScript developer for HubSpot in Cambridge, MA. He speaks at conferences including RailsConf, Øredev, and FluentConf. His first book, CoffeeScript: Accelerated JavaScript Development, was published by Pragmatic Bookshelf. You can follow him on Twitter at @TrevorBurnham.