This function dynamically loads an external JavaScript file.  If the file is already loaded, the function returns false.  If the load process initiated successfully, the function returns true.  If the parameter passed into the function is invalid (i.e. path is not specified), the function returns null.


  • path or config - the JavaScript path to load or a configuration object that specifies the JavaScript path to load along with other configuration options

Configuration Options:

  • path - the JavaScript path to load
  • callback - optional function to call once the JavaScript file is loaded
  • onerror - optional function to call if loading the JavaScript was unsuccessful
  • test - optional test function that can determine whether the JavaScript file was loaded successfully; if the test returns true before loading of the JavaScript is initiated, the process stops because the JavaScript is already loaded; if the test does not return true after the script has loaded, the callback is not called because the proper objects have not been loaded


Simple usage


Using config options

  path: "/profoundui/userdata/js/myfile.js",
  callback: function() {
    myfunction();  // if myfunction is defined in myfile.js, it should be safe to call it here; the file should have loaded by this time

Using config options to load the dojo library and test if it loaded properly

  path: "",
  callback: function() {
    // here, we can place code that will proceed to use the dojo library once it is fully loaded
  test: function() {
    return (typeof dojo != "undefined");  // return true if the dojo object is defined, false if undefined