Faster first load; demo date tags stay current

First load:
- Draw the Overview as soon as the data arrives instead of on its next
  2-second timer tick (about 2.5 s to 0.6 s on a typical connection).
- Start on DOMContentLoaded instead of window.onload.
- Load the ~900 KB PDF library only when someone exports a PDF.
- Fetch the startup files side by side, and build the docs search index
  after the dashboard has drawn (unless the visit starts on /docs).
- Show a loading placeholder on the Overview until the data arrives.

Demo: the date-batch tags sit on fixed working-day offsets from today.
The seed records them in Demo-Dates.json and the worker relabels them when
the day changes, so a long-running container never looks stale.
This commit is contained in:
Johan Sandoval committed 2026-10-07 20:22:09 +00:00
1 parent 5e8dea8027
commit 9731368687
8 files changed
+105 -21

No files matched your search

+10 -1
View File
@@ -295,6 +295,7 @@
jsPDF: { unit: 'mm', format: 'a4', orientation: 'portrait' },
pagebreak: { mode: ['css', 'legacy'], avoid: ['pre', 'table', 'img', 'blockquote', 'h1', 'h2', 'h3', 'h4', 'li', 'tr'] }
};
await loadHtml2Pdf();
await html2pdf().set(opt).from(page).toPdf().get('pdf').then(pdf => {
const n = pdf.internal.getNumberOfPages();
const w = pdf.internal.pageSize.getWidth(), h = pdf.internal.pageSize.getHeight();
@@ -382,8 +383,16 @@
};
addToolbarButtons();
// The search index fetches every article. On a first visit to any other page it waits
// until the device data has drawn, so those requests don't hold the dashboard up.
let indexReady = location.pathname.startsWith('/docs');
const indexNow = () => { if (indexReady) return; indexReady = true; reindex(); };
document.addEventListener('usmt:data', () => setTimeout(indexNow, 300), { once: true });
setTimeout(indexNow, 4000);
wrap('switchPage', id => { if (id === 'docs') indexNow(); });
wrap('loadDocsList', () => {
reindex();
if (indexReady) reindex();
if (firstLoad) {
firstLoad = false;
const t = titleFromPath();