Summary
One of our most prioritized goals is to reduce user-response time, that is, the application architecture must ensure the user flow is never blocked. This can be achieved by queuing any long-running tasks for asynchronous invocation. However, if you have a number of asynchronous calls among which some are intended to run in parallel and some sequentially, without taking special care, it's easy to run into a so-called Callback Hell. A proper use of such approaches as Continuation-passing style (Promise API), the Async/Await API, or an external library such as Async.js may significantly improve your asynchronous code. We also have to remember that some events such as scroll
/touch
/mousemove
, while being intensively fired, may cause unnecessary CPU load by calling subscribed listeners frequently. We can avoid these problems using debouncing and throttling techniques.
By learning the basis of asynchronous programming, we can write nonblocking applications. In Chapter 6, A Large-Scale JavaScript...