From 44a69e665ea5d2df55b762d65c269068c757e4d1 Mon Sep 17 00:00:00 2001 From: Jeff Emmett Date: Wed, 25 Mar 2026 17:03:21 -0700 Subject: [PATCH] perf(rmaps): preload MapLibre GL, switch CDN from unpkg to jsDelivr Add hints for MapLibre JS+CSS in the module HTML so the browser starts fetching them in parallel with the main bundle, instead of waiting until joinRoom() calls loadMapLibre(). Switch from unpkg (slow, no HTTP/2) to jsDelivr (faster edge caching). Co-Authored-By: Claude Opus 4.6 --- modules/rmaps/components/folk-map-viewer.ts | 4 ++-- modules/rmaps/mod.ts | 8 ++++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/modules/rmaps/components/folk-map-viewer.ts b/modules/rmaps/components/folk-map-viewer.ts index 868a8ed..6df9c44 100644 --- a/modules/rmaps/components/folk-map-viewer.ts +++ b/modules/rmaps/components/folk-map-viewer.ts @@ -23,8 +23,8 @@ import { startPresenceHeartbeat } from '../../../shared/collab-presence'; // MapLibre loaded via CDN — use window access with type assertion -const MAPLIBRE_CSS = "https://unpkg.com/maplibre-gl@4.1.2/dist/maplibre-gl.css"; -const MAPLIBRE_JS = "https://unpkg.com/maplibre-gl@4.1.2/dist/maplibre-gl.js"; +const MAPLIBRE_CSS = "https://cdn.jsdelivr.net/npm/maplibre-gl@4.1.2/dist/maplibre-gl.css"; +const MAPLIBRE_JS = "https://cdn.jsdelivr.net/npm/maplibre-gl@4.1.2/dist/maplibre-gl.js"; const OSM_ATTRIBUTION = '© OpenStreetMap contributors'; diff --git a/modules/rmaps/mod.ts b/modules/rmaps/mod.ts index 68606aa..9e7b050 100644 --- a/modules/rmaps/mod.ts +++ b/modules/rmaps/mod.ts @@ -274,7 +274,9 @@ routes.get("/", (c) => { spaceSlug: space, modules: getModuleInfoList(), body: ``, - scripts: ``, + scripts: ` + + `, styles: ``, })); }); @@ -291,7 +293,9 @@ routes.get("/:room", (c) => { modules: getModuleInfoList(), styles: ``, body: ``, - scripts: ``, + scripts: ` + + `, })); });