fix: add crossorigin and dedup check for CDN script loading

- Add crossorigin=anonymous for proper CORS caching across origins
- Skip re-loading scripts that already exist in head (SPA navigation)
This commit is contained in:
saberzero1 2026-05-24 17:22:55 +02:00
parent b9f718e558
commit 09bf6b4e2d
No known key found for this signature in database
5 changed files with 9 additions and 4 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

3
dist/index.js vendored

File diff suppressed because one or more lines are too long

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

View file

@ -19,9 +19,12 @@ import {
}
function loadScript(src) {
var existing = document.querySelector('script[src="' + src + '"]');
if (existing) return Promise.resolve();
return new Promise(function (resolve, reject) {
var script = document.createElement("script");
script.src = src;
script.crossOrigin = "anonymous";
script.onload = resolve;
script.onerror = reject;
document.head.appendChild(script);