1// loadScript: returns a promise that completes when the script loads 2window.loadScript = function (scriptPath) { 3 // check list - if already loaded we can ignore 4 if (loaded[scriptPath]) { 5 console.log(scriptPath + " already loaded"); 6 // return 'empty' promise 7 return new this.Promise(function (resolve, reject) { 8 resolve(); 9 }); 10 } 11 12 return new Promise(function (resolve, reject) { 13 // create JS library script element 14 var script = document.createElement("script"); 15 script.src = scriptPath; 16 script.type = "text/javascript"; 17 console.log(scriptPath + " created"); 18 19 // flag as loading/loaded 20 loaded[scriptPath] = true; 21 22 // if the script returns okay, return resolve 23 script.onload = function () { 24 console.log(scriptPath + " loaded ok"); 25 resolve(scriptPath); 26 }; 27 28 // if it fails, return reject 29 script.onerror = function () { 30 console.log(scriptPath + " load failed"); 31 reject(scriptPath); 32 } 33 34 // scripts will load at end of body 35 document["body"].appendChild(script); 36 }); 37} 38// store list of what scripts we've loaded 39loaded = [];
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.