Asynchronous JavaScript
In this module, we take a look atasynchronousJavaScript, why it is important, and how it can be used to effectively handle potential blocking operations, such as fetching resources from a server.
In this article
Prerequisites
Asynchronous JavaScript is a fairly advanced topic, and you are advised to work throughDynamic scripting with JavaScript modules before attempting this.
Tutorials and challenges
- Introducing asynchronous JavaScript
In this article, we'll learn aboutsynchronous andasynchronous programming, why we often need to use asynchronous techniques, and the problems related to the way asynchronous functions have historically been implemented in JavaScript.
- How to use promises
Here we'll introduce promises and show how to use promise-based APIs. We'll also introduce the
asyncandawaitkeywords.- Implementing a promise-based API
This article will outline how to implement your own promise-based API.
- Introducing workers
Workers enable you to run certain tasks in a separate thread to keep your main code responsive. In this article, we'll rewrite a long-running synchronous function to use a worker.
- Sequencing animationsChallenge
This challenge asks you to use promises to play a set of animations in a particular sequence.
See also
- Asynchronous Programming from the fantasticEloquent JavaScript online book by Marijn Haverbeke.