From c5ef9747286f4a268c6c7874c01b7a9bb990375b Mon Sep 17 00:00:00 2001 From: Chris Zuber Date: Tue, 5 May 2026 11:03:36 -0700 Subject: [PATCH] Do not load route in `init()` unless pattern / module is registered --- CHANGELOG.md | 5 +++++ package-lock.json | 4 ++-- package.json | 2 +- router.js | 9 ++++++--- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ad96f21..02256bf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [v1.2.1] - 2026-05-05 + +### Changed +- Do not load route in `init()` unless pattern / module is registered + ## [v1.2.0] - 2026-04-30 ### Added diff --git a/package-lock.json b/package-lock.json index 4a35e94..3f86fa7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@aegisjsproject/router", - "version": "1.2.0", + "version": "1.2.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@aegisjsproject/router", - "version": "1.2.0", + "version": "1.2.1", "funding": [ { "type": "librepay", diff --git a/package.json b/package.json index 78f7f79..ff2100a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@aegisjsproject/router", - "version": "1.2.0", + "version": "1.2.1", "description": "A simple but powerful router module", "keywords": [ "router", diff --git a/router.js b/router.js index d8c9513..b7e64d7 100644 --- a/router.js +++ b/router.js @@ -1159,9 +1159,6 @@ export async function init(routes, { observeLinksOn(inteceptRoot, { signal }); } - const content = await getModule(new URL(location.href)); - setScrollRestoration(scrollRestoration); - _updatePage(content); addPopstateListener({ signal }); if (typeof keyframes === 'object' && keyframes !== null) { @@ -1185,6 +1182,12 @@ export async function init(routes, { throw new AggregateError(errs.map(err => err.reason), 'Error initializing module routes.'); } }); + + if (ROUTES_REGISTRY.keys().some(pattern => pattern.test(location.href))) { + const content = await getModule(new URL(location.href)); + setScrollRestoration(scrollRestoration); + _updatePage(content); + } } return getNavSignal({ signal });