[fix](trx-frontend-http): fix map-core.js crash when cached scripts race app.js
Dynamic scripts (map-core.js etc.) are effectively async and can execute before the defer'd app.js that creates window.trx. When map-core.js is served from browser cache it loads instantly and crashes on `const T = window.trx` (undefined), preventing window.trx.map from ever being set — the map never initialises and Ctrl+R is needed. Move eager plugin loading from the inline script to app.js, triggered via window.loadEagerPlugins() after window.trx is fully populated. This guarantees the namespace exists before any plugin script runs. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Stan Grams <sjg@haxx.space>
This commit is contained in:
@@ -4766,6 +4766,10 @@ Object.defineProperties(window.trx, {
|
||||
locationSubtitle: { get() { return locationSubtitle; } },
|
||||
});
|
||||
|
||||
// Load plugin scripts now that window.trx is populated. Dynamic scripts are
|
||||
// async so they must not be created before the namespace they depend on exists.
|
||||
if (typeof window.loadEagerPlugins === "function") window.loadEagerPlugins();
|
||||
|
||||
// Start the app
|
||||
initializeApp();
|
||||
window.addEventListener("resize", resizeHeaderSignalCanvas);
|
||||
|
||||
Reference in New Issue
Block a user