O'Reilly logo

The Book of JavaScript, 2nd Edition by thau!

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Demonstrating Asynchronicity

Now it's time to have a deeper look at asynchronicity. Figure 14-5 demonstrates how two request objects can download files asynchronously. Here, clicking the Start Downloading button downloads two files, shortWait and longWait, which take different amounts of time for a webserver to process. The JavaScript behind this figure (shown in Figure 14-6) requests the file that takes the longest to process (longWait) first, and then requests the one that takes less time to process (shortWait).

Demonstrating asynchronicity

Figure 14-5. Demonstrating asynchronicity

Were these files to be downloaded synchronously, the script would download the slowest file—longWait—first, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required