perf(web): warm every primary route
This commit is contained in:
@@ -18,8 +18,9 @@ const importers: Record<RouteSection, () => Promise<RouteModule>> = {
|
||||
|
||||
const pendingModules = new Map<RouteSection, Promise<RouteModule>>();
|
||||
const backgroundPreloadOrder: RouteSection[] = [
|
||||
'monitor', 'tracks', 'history', 'statistics'
|
||||
'monitor', 'vehicles', 'tracks', 'history', 'statistics', 'alerts', 'access', 'operations'
|
||||
];
|
||||
const backgroundPreloadBatchSize = 2;
|
||||
|
||||
function loadRoute(section: RouteSection) {
|
||||
const pending = pendingModules.get(section);
|
||||
@@ -84,11 +85,9 @@ export function scheduleIdleRoutePreloads({
|
||||
|
||||
const warmNext = () => {
|
||||
if (cancelled) return;
|
||||
const section = queue.shift();
|
||||
if (!section) return;
|
||||
void Promise.resolve()
|
||||
.then(() => preload(`/${section}`))
|
||||
.catch(() => undefined)
|
||||
const batch = queue.splice(0, backgroundPreloadBatchSize);
|
||||
if (!batch.length) return;
|
||||
void Promise.allSettled(batch.map((section) => Promise.resolve().then(() => preload(`/${section}`))))
|
||||
.finally(() => {
|
||||
if (!cancelled) cancelScheduled = schedule(warmNext);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user