The Good Manager  >  Training modules

100 points to know about...
Eco-Design Web Development

100
points to know about...
Back to module summary

Notion 88

Asynchronous code: do more, in less time

Target skills

Understand through an example how asynchronous code is more efficient

What is asynchronous code

An asynchronous code is a piece of code being executed on a particular event. For example, clicking on a button can be seen as an event. It will trigger the execution of the button action.

The other advantage of asynchronous code, is that it is being executed at the same time of the rest of the program. It will not block other actions and allow for interactivity.

Why is it more efficient

By conditioning the execution of a piece of code and running it in parallel of the main code, we can have code executed only when needed, and without blocking the whole program.

A program making a request to a server will use an asynchronous function: it will be triggered by an event, and start asking a server for information. While the server is responding (it can take some time!), the program will not be blocked while it waits for an answer.

Asynchronous functions allow several actions to take place at the same time, without the program being blocked or overloaded if the expected condition never occurs.