scripts/loader-src.js
/**
     * try load script. If you need to download another script before
     * loading the script, wait until another script loads.
     * This function is called recursively at the end of loading each script
     * until all the scripts are loaded. When all the scripts are loaded, we call the
     * callback if it was specified
     * */
try load script. If you need to download another script before
loading the script, wait until another script loads.
This function is called recursively at the end of loading each script
until all the scripts are loaded. When all the scripts are loaded, we call the
callback if it was specified
try load script . If you need to download another script before loading the script wait until another script loads . This function is called recursively at the end of loading each script until all the scripts are loaded . When all the scripts are loaded we call the callback if it was specified
tryLoad() {
        let isAllLoaded = true;
        for (let scriptname in this.scripts) {
            if (this.isNeeded(scriptname)) {
                isAllLoaded = false;
                let afterScripts = this.scripts[scriptname].after;
                let loadAccess = true;
                if (afterScripts) {
                    for (let ii = 0, ilen = afterScripts.length; ii < ilen; ii++) {
                        if (!this.checkIsLoaded(afterScripts[ii])) {
                            loadAccess = false;
                            if (info) {
                                console.log('load script:"%s" need load after:"%s"', scriptname, afterScripts[ii]);
                            }
                            break;
                        }
                    }
                }
                if (loadAccess && this.scripts[scriptname].isLoaded !== this.stages.started) {
                    this.scripts[scriptname].isLoaded = this.stages.started;
                    if (info) {
                        console.log('load script started %s', scriptname);
                    }
                    this.requireScript(scriptname);
                }
            }
            if(!this.checkIsLoaded(scriptname)) {
                isAllLoaded = false;
            }
        }
        if(isAllLoaded) {
            if (info) {
                console.log('all script loaded');
            }
            if (this.cfg.onLoad) {
                this.cfg.onLoad();
            }
        }
    }
tryLoad ( ) { let isAllLoaded = true ; for ( let scriptname in this . scripts ) { if ( this . isNeeded ( scriptname ) ) { isAllLoaded = false ; let afterScripts = this . scripts [ scriptname ] . after ; let loadAccess = true ; if ( afterScripts ) { for ( let ii = 0 , ilen = afterScripts . length ; ii < ilen ; ii ++ ) { if ( ! this . checkIsLoaded ( afterScripts [ ii ] ) ) { loadAccess = false ; if ( info ) { console . log ( 'load script:"%s" need load after:"%s"' , scriptname , afterScripts [ ii ] ) ; } break ; } } } if ( loadAccess && this . scripts [ scriptname ] . isLoaded !== this . stages . started ) { this . scripts [ scriptname ] . isLoaded = this . stages . started ; if ( info ) { console . log ( 'load script started %s' , scriptname ) ; } this . requireScript ( scriptname ) ; } } if ( ! this . checkIsLoaded ( scriptname ) ) { isAllLoaded = false ; } } if ( isAllLoaded ) { if ( info ) { console . log ( 'all script loaded' ) ; } if ( this . cfg . onLoad ) { this . cfg . onLoad ( ) ; } } }
try load script.
try load script .
// isAllLoaded = false;