refactor: remove unnecessary DOMContentLoaded wrappers

Since main.js has 'defer' attribute, the DOM is guaranteed to be
ready when modules execute. These wrappers are unnecessary.

dashboard.ts:
- Removed DOMContentLoaded wrapper, code runs directly
- Event delegation setup runs immediately

custom-section-builder.ts:
- Removed DOMContentLoaded wrapper
- initCustomSectionBuilder() called directly

toast.ts:
- Removed DOMContentLoaded wrapper
- initializeToastSystem() called directly at top level
- Removed dead Alpine.data registration (unused)

search.ts:
- Removed DOMContentLoaded wrapper
- initializeSearch exported for use in header

theme.ts:
- Removed DOMContentLoaded wrapper
- Functions now exported for use in header Alpine component
This commit is contained in:
2026-03-13 12:51:16 -04:00
parent 41e7445524
commit 2075077bb7
5 changed files with 64 additions and 94 deletions
+6 -15
View File
@@ -202,24 +202,15 @@ const updateWoodPanelingIndicators = (): void => {
});
};
// Auto-initialize when DOM is ready
if (typeof document !== "undefined") {
if (document.readyState === "loading") {
document.addEventListener("DOMContentLoaded", () => {
initializeTheme();
loadWoodPaneling();
updateWoodPanelingIndicators();
});
} else {
initializeTheme();
loadWoodPaneling();
updateWoodPanelingIndicators();
}
}
Alpine.data("theme", () => ({
applyTheme,
changeTheme,
changeWoodPaneling,
initializeTheme,
loadTheme,
loadUserTheme,
loadWoodPaneling,
updateWoodPanelingIndicators,
}));
export {