So können Sie uns unterstützen
The examples so far focus on coupling a single external script with inlined code. This is useful in many situations where the JavaScript framework being used is contained in a single file, such as Google Analytics and jQuery. Often, however, we have multiple external scripts and an inline script, all of which must be executed in the order specified. None of the techniques described so far, both here and in Chapter 4, provide a means to preserve order while loading multiple scripts asynchronously. There is no complete solution to this problem, primarily due to browser inconsistencies.
In order to have an example that uses multiple scripts, I created menutier.js. This new script extends the menu functionality to give a tiered or grouped menu, as shown in Figure 5-4 (notice the shaded group headings). In addition, menutier.js depends on menu.js, so their execution order must be preserved. A tiered menu is created in the inlined code by calling EFWS.Menu.createTieredMenu. This sets up the situation we’re trying to analyze: multiple external scripts and an inline script that must be executed in order. Furthermore, menutier.js is configured to return before menu.js on which it depends. Are we headed for trouble? Let’s look at how the Managed XHR and DOM Element and Doc Write techniques load the external scripts in parallel while preserving execution order.
