The home page shows at once
It was blank until every module had loaded and the page's examples had been run, a fuzzer's report among them (about a second of work): first paint came 1.3 seconds into a repeat visit and about 3 into a first one. - The assembler draws the home page once, in Node, with the app's own homeView, and puts it inside #app. The browser paints it with the HTML and the stylesheet. - When the app has loaded it draws the page again, with its controls, and puts it in the prerendered one's place; the fuzzer's reports and the proof's counts are copied from the prerendered page, not worked out again. - The prerendered page shows only on the home address: the page's first inline script marks it before the first paint, and without the mark it stays hidden, so an embed or a problem's address never shows it. That script changed, and its hash in docs/Caddyfile with it. Served locally, first paint is at 0.1 to 0.2 seconds and the page with its controls at 0.2 to 0.3; both were at 1.2 to 1.4.
This commit is contained in:
12 files changed
+154
-19
No files matched your search
+7
-2
@@ -12,6 +12,7 @@ import { parseRoute, decodeState, loadLocal, migrateLocal, type PlayState, embed
|
||||
import { takeCrashed, settle, setAside, markBusy } from './core/guard.js';
|
||||
import { notice, messagePage } from './ui/notice.js';
|
||||
import { homeView } from './ui/home.js';
|
||||
import { prerenderedHome } from './ui/prerender.js';
|
||||
import { siteNav } from './ui/nav.js';
|
||||
import { quartoView } from './ui/quarto.js';
|
||||
import { libraryView } from './ui/library.js';
|
||||
@@ -133,7 +134,9 @@ async function show(): Promise<void> {
|
||||
// the same static page with only the anchor changed: scroll, do not rebuild
|
||||
if (!shell && anchorOnly(location.hash, app.firstElementChild ? [...app.firstElementChild.classList] : null)) { scrollToAnchor(); return; }
|
||||
shell?.destroy(); shell = null;
|
||||
clear(app);
|
||||
// the home page drawn by the assembler stays on screen until the one with its controls is ready to take its place
|
||||
const prerendered = route.kind === 'home' ? prerenderedHome() : null;
|
||||
if (!prerendered) clear(app);
|
||||
document.body.classList.remove('is-embed');
|
||||
let resolved: Resolved;
|
||||
try { resolved = await stateForRoute(); } catch (e: any) {
|
||||
@@ -150,7 +153,9 @@ async function show(): Promise<void> {
|
||||
if (!resolved && route.kind === 'library') { add(app, libraryView(route.id)); document.title = `${route.id ? `${route.id} · ` : ''}Library · Programming+`; window.scrollTo(0, 0); return; }
|
||||
if (!resolved && route.kind === 'quarto') { add(app, quartoView()); document.title = 'With Quarto · Programming+'; if (route.anchor) scrollToAnchor(true); else window.scrollTo(0, 0); return; }
|
||||
if (!resolved) {
|
||||
add(app, homeView()); document.title = HOME_TITLE; scrollToAnchor(true);
|
||||
const home = homeView();
|
||||
if (prerendered) clear(app);
|
||||
add(app, home); document.title = HOME_TITLE; scrollToAnchor(true);
|
||||
if (isUnknownRoute(location.hash)) notice('There is no page at that address, so this is the home page. Links from before the three areas open here too.');
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user