diff --git a/src/trx-client/trx-frontend/trx-frontend-http/assets/web/app.js b/src/trx-client/trx-frontend/trx-frontend-http/assets/web/app.js index cfe931b..0d2c435 100644 --- a/src/trx-client/trx-frontend/trx-frontend-http/assets/web/app.js +++ b/src/trx-client/trx-frontend/trx-frontend-http/assets/web/app.js @@ -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); diff --git a/src/trx-client/trx-frontend/trx-frontend-http/assets/web/index.html b/src/trx-client/trx-frontend/trx-frontend-http/assets/web/index.html index 8e5a3e5..1fda642 100644 --- a/src/trx-client/trx-frontend/trx-frontend-http/assets/web/index.html +++ b/src/trx-client/trx-frontend/trx-frontend-http/assets/web/index.html @@ -1646,12 +1646,13 @@ document.body.appendChild(s); }); } - // Load core plugins immediately (needed on main tab). - // 'map-data' loads map-core.js + data handlers (ais/aprs/vdes/hf-aprs) eagerly - // so decode history replay can populate map data structures before the map - // tab is opened. The 'loaded' Set prevents double-loading when the map tab - // is later activated. - ['digital-modes', 'map-data', 'bookmarks', 'settings'].forEach(loadPlugins); + // Eager plugin loading is triggered by app.js (after window.trx is set up) + // via window.loadEagerPlugins(). Dynamic scripts are effectively async, so + // loading them before app.js would cause map-core.js to crash when + // window.trx is not yet defined. + window.loadEagerPlugins = function() { + ['digital-modes', 'map-data', 'bookmarks', 'settings'].forEach(loadPlugins); + }; // Load others on tab switch document.addEventListener('click', function(e) { var tab = e.target.closest('[data-tab]');