Java2Script ClassLoader’s Loading Modes
Tuesday, May 8th, 2007There are 3 loading modes in Java2Script ClassLoader.
- Loading classes by using <SCRIPT> tag asynchronously (Default mode).
- Loading classes by XMLHttpRequest(XHR) asynchronously.
- Loading classes by XHR synchronously (May freeze UI when classes are loading).
In order to switch to different loading mode, execute the following line after j2slib.z.js is loaded:
ClazzLoader.setLoadingMode (”xhr.async”); // XHR asynchronously loading
or
ClazzLoader.setLoadingMode (”xhr”); // XHR synchronously loading
or
ClazzLoader.setLoadingMode (”script”); // <SCRIPT> asynchronously loading. No synchronously loading
In asynchronously loading mode, you can specify a time lag between two *.js loading. The time lag may be useful for the browser (Internet Explorer) to update its UI changes. To set time lag as the following examples:
ClazzLoader.setLoadingMode (”xhr.async”, 5); // 5 ms lag
or
ClazzLoader.setLoadingMode (”script”, 5);
But
ClazzLoader.setLoadingMode (”xhr”, 5); // synchronously loading
makes no senses, as there are no time lag in synchronously loading mode.
For more information, please read Java2Script’s ClassLoader source.