//-- call back founction var cb = function(app) { run(app.jQuery); } // application signiture. // must be unique per application var app_sig = ""; // check if app_sig is already available globally if ( app_sig in window ) { // if available, then get the app info record var app = window[app_sig]; // check if all the main script was loaded if ( app.b_loaded ) { // the main script is loaded! execute the call back function! cb(app); } else { // the main script hasn't been loaded yet, let's que it to cb_list. app.cb_list.push(cb); } } else { // app_sig is not available, so this is the first time. // put the call back founctin in cb_list window[app_sig] = {b_loaded:false,cb_list:[cb]}; // load script, this must be jQuery loadScript('',function(){ // now jquery was loaded. // 'jQuery' contains the one loaded now. // let's get app record. var app = window[app_sig]; // store the jQuery we just loaded now. app.jQuery = window.jQuery; // Put the previously jQuery into the global namespace jQuery.noConflict( true ); // The second load! This time, we'll load the application script loadScript('',function(){ // all the script is loaded, so flag 'b_loaded' app.b_loaded = true; // run the loaded script with our jQuery tSShow.loadScript(app.jQuery); // execute all the callback function we stored so far. for(var i=0; i