From d123eda869770a132ba0c13bf99444971b6e3f0b Mon Sep 17 00:00:00 2001 From: librelad Date: Tue, 26 May 2026 22:25:36 +0100 Subject: [PATCH] perf(webui): defer page-specific scripts to first navigation (Phase B) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 7 page-specific controllers were eager-loaded in index.html on every cold visit, even when the user lands on /dashboard and never opens /backup, /admin, etc. Moved them to lazy-load via spa.js's existing loadScript() helper, fired from each route's handler on first navigation: /js/components/backup/backup-page.js — handleBackup() /js/components/backup/backup-app-card.js — handleBackup() /js/components/ssh/ssh-page.js — config-manager ssh-access /js/components/peers/peers-page.js — config-manager peers /js/components/admin/admin-overview.js — config-manager overview /js/components/admin/charts.js — config-manager overview /js/components/admin/admin-system.js — config-manager system config-manager.js gets a tiny `lazyLoad` helper that delegates to window.spaClean.loadScript with a graceful fallback when the SPA hasn't booted (legacy paths). loadScript is idempotent — subsequent visits to the same route are no-ops, so we don't re-fetch after the first nav. Cold-load impact on /dashboard (the most common landing): Before: 25 sync - - - - - - - + diff --git a/containers/libreportal/frontend/js/components/config/config-manager.js b/containers/libreportal/frontend/js/components/config/config-manager.js index e1f2ca5..7028904 100755 --- a/containers/libreportal/frontend/js/components/config/config-manager.js +++ b/containers/libreportal/frontend/js/components/config/config-manager.js @@ -32,9 +32,21 @@ if (typeof window.ConfigManager === 'undefined') { // the first call, so the config-category path below is a cache hit. try { await this.core.loadConfig(category); } catch (e) {} + // Tool controllers are loaded on demand — they're not in index.html's + // initial