overview / js /bootstrap.js
Yacine Jernite
v08
72be969
// bootstrap.js - SINGLE ENTRY POINT for application initialization
// This is the ONLY file that auto-executes
// All initialization happens here in a well-defined sequence
async function bootstrap() {
try {
// Step 1: Load artifacts (areas already loaded in <head>)
const { loadArtifacts } = await import('./init.js');
await loadArtifacts();
// Step 2: Initialize router (will render initial page)
const { router } = await import('./utils/router.js');
// Router auto-initializes in constructor, no need to call init()
// Step 3: Initialize UI components (search, scroll-to-top, etc.)
const { initializeUI } = await import('./main.js');
await initializeUI();
} catch (error) {
console.error('Bootstrap failed:', error);
// Show user-friendly error
const mainContent = document.getElementById('main-content');
if (mainContent) {
mainContent.innerHTML = `
<div class="p-8 text-center">
<h2 class="text-2xl font-bold text-red-600 mb-4">Failed to Load Application</h2>
<p class="text-gray-700 mb-4">Please refresh the page. If the problem persists, contact support.</p>
<pre class="text-left text-sm bg-gray-100 p-4 rounded overflow-auto">${error.stack || error.message}</pre>
</div>
`;
}
}
}
// Start immediately when module loads
bootstrap();