How to use rslib

rsLIB :: Code

If you need to use a variable or execute any library function immediately, it should be within the event rsLIB.onComplete(callback) passing a function as a callback.
For example, if you need to use the variable objLanguage it which is defined in an external script imported by this loader, would::

window.addEventListener("load",   
    function
pageLoaded(){
   
      /* rsLIB.onComplete(callback) function passing a function as a callback. */
   
      rsLIB
.onComplete(
    
        function
callBack01(){ //callback
     
          document
.getElementById("container").innerHTML = "Language: " + objLanguage.language ;
    
        }    
      );   
    }
  , false);

DYNAMIC loading is something NO-STANDARD employing an UNORTHODOX way and can cause different behaviors in certain browsers ... When produced a modification of DOM at the same time it is building its ELEMENT TREE incurred in a kind of contradiction is solved differently in different browsers.

P.D.: Some libraries NEED synchronous mode for proper operation)

'onComplete( callback )' EVENT:

This method has been implemented to wait to use variables which were defined a immediately manner. These variables must be executed in the CALLBACK function passed as a parameter. For Example:

/** An event callback function which include with the immediate code
   * @param callback */
  
rsLIB
.onComplete( function callBack(){
   
    //code to execute when the scripts are loaded (the main)
  
});

THE 'rsLIB' OBJECT:

Once interpreted the file rsLIB.js, it create the global variable rsLIB' representing the LOADER object. The following members are created:

  • options: the complete object detected as embedded options.
  • nameLIB: name of the library to load.
  • pathToLIB: the path to the library, based on the situation of HTML caller.
  • scripts: the array of scripts to load the library.
  • get: get properties of embedded object.
  • isset: utility method to check whether a variable is undefined.
  • onComplete(..): The event method to which can be passed a 'callback' function as the only parameter.