This page contains an external script and some inlined code that depends on the external script.
The external script, menu.js, is loaded asynchronously.
The inlined code's init function calls EFWS.Menu.createMenu(), a function defined in the external script.
Because of this dependency, the inlined code must be coupled with the external script so that the execution order is preserved: the external script is loaded, parsed, and executed before the inlined code.
In this example, the scripts are loaded using document.write to write the SCRIPT tags into the page.
document.write('<script src="menu.js" type="text/javascript"><\/script>');
This technique successfully loads scripts in parallel in IE, Safari 4, and Opera, and it preserves execution order. But it has some drawbacks. Although scripts are loaded in parallel, in IE and Opera other types of resources (images, stylesheets, etc.) are blocked from downloading, elements in the page below the scripts are blocked from rendering, and it doesn't preserve execution order.
Takeaway: If you use these asynchronous script loading techniques, you need to use a coupling technique to avoid undefined symbol errors.