Chapter 5. Asynchronous JavaScript
Nowadays Internet users are impatient, a lag of 2-3 seconds during page loading or navigation and they lose their interest and will likely leave the service for something else. Our highest priority is to reduce user response time. The main approach here is known as Cutting the mustard (http://www.creativebloq.com/web-design/responsive-web-design-tips-bbc-news-9134667). We extract the components of an application required for core experience and load them first. Then, progressively we add an enhanced experience. As for JavaScript, what we have to care the most about are nonblocking flows. Thus, we have to avoid loading scripts synchronously prior to HTML rendering, and we have to wrap all long-running tasks into asynchronous callbacks. This is something that you most probably already know. But do you do it efficiently?
In this chapter, we will cover the following topics:
- Nonblocking JavaScript
- Error-first callback
- The continuation-passing style
- Handling...