Asynchronous JavaScript
In this module we take a look at asynchronous JavaScript, why it is important, and how it can be used to effectively handle potential blocking operations such as fetching resources from a server.
Looking to become a front-end web developer?
We have put together a course that includes all the essential information you need to work towards your goal.
Prerequisites
Asynchronous JavaScript is a fairly advanced topic, and you are advised to work through JavaScript first steps and JavaScript building blocks modules before attempting this.
Guides
- Introducing asynchronous JavaScript
-
In this article we'll see what synchronous and asynchronous programming are, why we often need to use asynchronous techniques, how asynchronous functions have historically been implemented in JavaScript, and what their problems are.
- How to use promises
-
Here we'll introduce promises and show how to use promise-based APIs. We'll also introduce the
async
andawait
keywords. - Implementing a promise-based API
-
This article outlines 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.
Assessments
- Sequencing animations
-
The assessment asks you to use promises to play a set of animations in a particular sequence.
See also
- Asynchronous Programming from the fantastic Eloquent JavaScript online book by Marijn Haverbeke.