refactor(client): handle everything in bootstrap

This commit is contained in:
Elian Doran 2026-01-07 21:11:38 +02:00
parent 2e845a9faa
commit 7a088c5b7d
No known key found for this signature in database
2 changed files with 14 additions and 11 deletions

View File

@ -13,11 +13,6 @@
<body id="trilium-app">
<noscript><%= t("javascript-required") %></noscript>
<script>
// hide body to reduce flickering on the startup. This is done through JS and not CSS to not hide <noscript>
document.getElementsByTagName("body")[0].style.display = "none";
</script>
<div class="dropdown-menu dropdown-menu-sm" id="context-menu-container" style="display: none"></div>
<!-- Required for match the PWA's top bar color with the theme -->

View File

@ -1,9 +1,6 @@
import $ from "jquery";
async function bootstrap() {
(window as any).$ = $;
(window as any).jQuery = $;
showSplash();
await initJQuery();
await setupGlob();
await loadBootstrapCss();
loadStylesheets();
@ -13,6 +10,12 @@ async function bootstrap() {
hideSplash();
}
async function initJQuery() {
const $ = (await import("jquery")).default;
(window as any).$ = $;
(window as any).jQuery = $;
}
async function setupGlob() {
const response = await fetch(`/bootstrap${window.location.search}`);
const json = await response.json();
@ -93,8 +96,13 @@ async function loadScripts() {
}
}
function showSplash() {
// hide body to reduce flickering on the startup. This is done through JS and not CSS to not hide <noscript>
document.body.style.display = "none";
}
function hideSplash() {
$("body").show();
document.body.style.display = "block";
}
bootstrap();