web: a hover on a link to a kept page preloads its route's code and css, so the page paints right after it commits
Signed-off-by: dawn <dawn@tangled.org>
12345647 unmodified lines545556575657585859606162636465666768697071727358 unmodified linesimport { preloadCode } from "$app/navigation";import { match } from "$app/paths";import { sessionCached } from "#lib/sessionCache.ts";
// on a knot every url answers, but only the pages its renderer kept are worth loading as a// document: those paint at once, while the rest would boot the app from scratch. so a link to47 unmodified lines if (!known.has(root)) { learn(root); return; } if (known.get(root)?.has(routeOf(new URL(anchor.href), root))) anchor.dataset.sveltekitReload = ""; else delete anchor.dataset.sveltekitReload; if (!known.get(root)?.has(routeOf(new URL(anchor.href), root))) { delete anchor.dataset.sveltekitReload; return; } anchor.dataset.sveltekitReload = ""; // sveltekit preloads no reload link, so the next page fetches its route's css before its first // paint while the old page's last frame stays up. a hover fetches it ahead, also where the // browser's own preloading is off if (event.type !== "click") void match(anchor.href) .then((route) => route && preloadCode(route.id)) .catch(() => {});};
type NavigateEvent = Event & { destination: { sameDocument: boolean };58 unmodified lines