From 344a3f7bb2393888a8d3313052d897caa2f45f30 Mon Sep 17 00:00:00 2001 From: artheru Date: Wed, 10 Jun 2026 09:25:33 +0800 Subject: [PATCH] perf: preload tavern canvas tiles on the main domain (0.69.0) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - the LPC scene images only started downloading after the Scene2D chunk loaded and TavernGame mounted, extending the 'loading tavern…' flash - preload them in main.jsx (gated to the main domain via App===Scene2DApp, so docs/pm don't fetch them) — they now download in parallel with the JS chunk - verified live: images requested at 1461ms vs Scene2D chunk at 1467ms (before, in parallel), canvas renders correctly --- index.html | 2 +- package.json | 2 +- src/Scene2D.jsx | 2 +- src/main.jsx | 9 +++++++++ 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/index.html b/index.html index d5fbca1..7fd051c 100644 --- a/index.html +++ b/index.html @@ -4,7 +4,7 @@ - + diff --git a/package.json b/package.json index 892254a..20ff657 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "amerc-site", - "version": "0.68.0-trim", + "version": "0.69.0-preload", "private": true, "type": "module", "scripts": { diff --git a/src/Scene2D.jsx b/src/Scene2D.jsx index 38b9baa..ac0325c 100644 --- a/src/Scene2D.jsx +++ b/src/Scene2D.jsx @@ -7,7 +7,7 @@ import Account from './Account.jsx'; import TavernGame from './TavernGame.jsx'; import { api } from './api.js'; -const RELEASE = '0.68.0-trim'; +const RELEASE = '0.69.0-preload'; const NAV = [ { id: 'home', label: 'Tavern' }, diff --git a/src/main.jsx b/src/main.jsx index 43c96ca..10f9e01 100644 --- a/src/main.jsx +++ b/src/main.jsx @@ -12,6 +12,15 @@ let App = Scene2DApp; if (host.startsWith('docs.')) App = DocsApp; else if (host.startsWith('pm.')) App = PmApp; +// Preload the tavern's canvas tiles on the main domain so the scene paints as +// soon as the app mounts — they download in parallel with the JS chunk instead +// of only after TavernGame runs. Not needed on docs/pm. +if (App === Scene2DApp) { + for (const n of ['inside', 'castlefloors', 'victoria', 'barrel', 'princess', 'soldier', 'soldier_altcolor']) { + const im = new Image(); im.src = `/scene2d/lpc/${n}.png`; + } +} + // Catch render errors so a single bad component can't blank the whole app. class ErrorBoundary extends React.Component { constructor(props) { super(props); this.state = { error: null }; }