mirror of
https://github.com/quartz-community/graph.git
synced 2026-07-22 02:50:25 +00:00
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:
parent
b9f718e558
commit
09bf6b4e2d
5 changed files with 9 additions and 4 deletions
3
dist/components/index.js
vendored
3
dist/components/index.js
vendored
File diff suppressed because one or more lines are too long
2
dist/components/index.js.map
vendored
2
dist/components/index.js.map
vendored
File diff suppressed because one or more lines are too long
3
dist/index.js
vendored
3
dist/index.js
vendored
File diff suppressed because one or more lines are too long
2
dist/index.js.map
vendored
2
dist/index.js.map
vendored
File diff suppressed because one or more lines are too long
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in a new issue