Java2Script ClassLoader’s Loading Modes

There are 3 loading modes in Java2Script ClassLoader.

  1. Loading classes by using <SCRIPT> tag asynchronously (Default mode).
  2. Loading classes by XMLHttpRequest(XHR) asynchronously.
  3. 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


ClazzLoader.setLoadingMode (“xhr”); // XHR synchronously loading


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


ClazzLoader.setLoadingMode (“script”, 5);


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.

This entry was posted in Java2Script. Bookmark the permalink.

Comments are closed.