mirror of
https://github.com/Nystik-gh/ignis.git
synced 2026-06-17 04:35:53 +00:00
hold Obsidian boot until the priority cache slice loads
This commit is contained in:
@@ -65,25 +65,67 @@
|
||||
}, 250);
|
||||
}
|
||||
|
||||
update();
|
||||
function appendScripts() {
|
||||
// No Obsidian scripts to load (markup or scrape mismatch); clear the splash instead of pulsing forever.
|
||||
if (scripts.length === 0) {
|
||||
done();
|
||||
return;
|
||||
}
|
||||
|
||||
for (var i = 0; i < scripts.length; i++) {
|
||||
var s = document.createElement("script");
|
||||
s.type = "text/javascript";
|
||||
s.src = scripts[i];
|
||||
s.async = false;
|
||||
s.onload = function () {
|
||||
loaded++;
|
||||
update();
|
||||
if (loaded === scripts.length) done();
|
||||
};
|
||||
s.onerror = function () {
|
||||
loaded++;
|
||||
update();
|
||||
if (loaded === scripts.length) done();
|
||||
};
|
||||
document.body.appendChild(s);
|
||||
update();
|
||||
|
||||
for (var i = 0; i < scripts.length; i++) {
|
||||
var s = document.createElement("script");
|
||||
s.type = "text/javascript";
|
||||
s.src = scripts[i];
|
||||
s.async = false;
|
||||
s.onload = function () {
|
||||
loaded++;
|
||||
update();
|
||||
if (loaded === scripts.length) done();
|
||||
};
|
||||
s.onerror = function () {
|
||||
loaded++;
|
||||
update();
|
||||
if (loaded === scripts.length) done();
|
||||
};
|
||||
document.body.appendChild(s);
|
||||
}
|
||||
}
|
||||
|
||||
// Hold Obsidian's scripts until the shim signals the priority cache slice has landed (window.__ignisBootReady), so Obsidian's early config and plugin reads hit the warm cache.
|
||||
// A timeout proceeds anyway, so a missing or never-resolving promise degrades to loading immediately instead of blocking boot.
|
||||
var ready = window.__ignisBootReady;
|
||||
if (!ready || typeof ready.then !== "function") {
|
||||
appendScripts();
|
||||
return;
|
||||
}
|
||||
|
||||
var started = false;
|
||||
|
||||
function start() {
|
||||
if (started) {
|
||||
return;
|
||||
}
|
||||
|
||||
started = true;
|
||||
// Tell the shim's progress writer to stop touching the splash label now that we own it.
|
||||
window.__ignisBootStarted = true;
|
||||
appendScripts();
|
||||
}
|
||||
|
||||
var timer = setTimeout(start, 3000);
|
||||
|
||||
ready.then(
|
||||
function () {
|
||||
clearTimeout(timer);
|
||||
start();
|
||||
},
|
||||
function () {
|
||||
clearTimeout(timer);
|
||||
start();
|
||||
},
|
||||
);
|
||||
})();
|
||||
</script>
|
||||
</body>
|
||||
|
||||
Reference in New Issue
Block a user