Dynamic JavaScript Loading
I wanted to discuss the technique of dynamic loading of JavaScript and compare the approach used in Authenteo to other systems.
Dynamic JavaScript loading is very significant because as we start to develop more advanced rich internet applications, we start to be hampered by the limitation of loading all of our JavaScript when the page loads. We would consider it to be a very serious limitation indeed if Java, or C#, or anything else had to load every bit of code that might potentially be used, when you started your application. Likewise, it is very limiting if your application must load all the code that the user might utilize at page load. This might not be too much of a problem for simple web pages, but as web applications become more sophisticated you start having more code and functions that are utilizing only occasionally by users.
This provides a great opportunity for JavaScript that is not needed very often to be loaded only when needed. However, this comes with a cost. Unfortunately, with JavaScript if you want to truly suspend execution while waiting for a remote call to take place, you must use a synchronous call. A synchronous basically stops the single browser thread until the request is responded to. This suspension doesn?t just affect your JavaScript, but your whole browser. Basically your browser is ?locked up? until the request returns. On a slow connection this can be a painful and disturbing thing for a user.
Authenteo also provides dynamic loading of JavaScript. However, it utilizes a package called Narrative JavaScript to provide JavaScript preprocessing to emulate continuations. A continuation allows a call stack to be suspended and resumed later, and this can be done asynchronously. Therefore this allows Authenteo to suspend the execution of a JavaScript function, and retrieve requested data, and then resume execution using an asynchronous call that does not lock up the browser.