MCPcopy Create free account
hub / github.com/error311/FileRise / loadScriptOnce

Function loadScriptOnce

public/js/upload.js:475–488  ·  view source on GitHub ↗
(src)

Source from the content-addressed store, hash-verified

473let _resumableLoadPromise = null;
474
475function loadScriptOnce(src) {
476 if (loadScriptOnce._cache?.has(src)) return loadScriptOnce._cache.get(src);
477 loadScriptOnce._cache = loadScriptOnce._cache || new Map();
478 const p = new Promise((resolve, reject) => {
479 const s = document.createElement('script');
480 s.src = src;
481 s.async = true;
482 s.onload = resolve;
483 s.onerror = () => reject(new Error(`Failed to load ${src}`));
484 document.head.appendChild(s);
485 });
486 loadScriptOnce._cache.set(src, p);
487 return p;
488}
489
490function lazyLoadResumable() {
491 if (window.Resumable) return Promise.resolve(window.Resumable);

Callers 1

lazyLoadResumableFunction · 0.70

Calls 2

setMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected