Created
July 8, 2023 21:13
-
-
Save dman777/6b827c900b6f38c0d877392fcb0ad0f6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#downloadJSPdf() { | |
const loadJspdf = (() => { | |
async function actuallyLoad() { | |
const script = document.createElement('script'); | |
script.src = 'https://cdnjs.cloudflare.com/ajax/libs/jspdf/2.5.1/jspdf.umd.min.js'; | |
await new Promise((resolve, reject) => { | |
script.addEventListener('error', reject); | |
script.addEventListener('load', resolve); | |
document.head.appendChild(script); | |
}); | |
} | |
let loadingPromise; | |
return async () => { | |
if (loadingPromise === undefined) { | |
loadingPromise = actuallyLoad(); | |
} | |
return loadingPromise; | |
}; | |
})(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment