Typically, web pages define JavaScript functions and objects, as well as CSS style-rules statically, by means of script and link elements within the head element. However, it is also possible to load such code dynamically, such that applications import functionality only when required.
This approach is far more efficient, as it consumes bandwidth and platform resources only when necessary, and this section presents a library of three small functions that automate the techniques involved.
Critically, these functions can be used in conjunction with AspectJS, and this is significant because the intersection of the technologies permits code downloads on demand but entirely transparently at the point of need. This is explored in the AspectJS Applications page entitled On-Demand Loading, and in the article entitled Transparency on Demand.
The functions that comprise the library are as follows:
Note that, unlike the other libraries available on this site, there are no 'DbC' adjunct-functions for these resources currently (for the purposes of performing argument type, number and value checking), although this may be addressed at some point.
| Tutorials |
Using loadJS_XHR |
| APIs | |