Of course the first step starts loading the script. We use the tag HTML < script ... / > in the Head page.
The script handles dynamically import scripts / libraries listed in the options and, once completed, built a GLOBAL object rsLIB, which contains some interesting properties and methods, among others, a very useful event onComplete (..) to pass a callback. You only need to use it if you do use a resource immediately (variable, method, object ...) from loaded library.
We import the script in the Head page area, for example:
<script id="rsLIB_ID" class="rsLIB_CLASS" type="text/javascript" src="./scripts/rsLIB.js"> {JAVASCRIPT OPTIONS} </script>
The most interesting thing here is the area marked as braces {JAVASCRIPT OPTIONS}. Well, this is the way in which the script will pick the passed option, which must be a object Javascript.
As already mentioned, rsLIB works with options and these are expected as an object embedded within the tag script of the own call to this loader. These options should appear as follows:
The call in the HTML Head might be:
/* Anonymous object for options */
{
nameLIB: "PolyArea",
pathToLIB: "./scripts/PolyArea/",
scripts: ["./scripts/PolyArea/PolyArea.js",
"./scripts/PolyArea/css/polyArea.css",
"./scripts/PolyArea/PolyArea.js"] //The latter will not be loaded, only determines 'onComplete (..)' event
}
For reasons of safety the options will be destroyed after use, leaving no trace in the HTML generated, helping to increase the SECURITY layer and ABSTRACTION.