forrtproject / forrtproject/forrtproject.github.io
Lazy-load the global search index
- Vorherrschende Sprache
- HTML
- Sterne
- 42
- Forks
- 33
- Ø Merge
- 2 T. 6 Std.
- Gemergte PRs (30 T.)
- 19
Beschreibung
## Why this needs addressing
The current Fuse search bundle fetches `/index.json` during initialization, before a visitor opens or uses search. The live index is approximately 2.3 MB uncompressed (about 646 KB gzipped), and the homepage includes the search bundle. This cost is paid on ordinary page views across the site.
Relevant implementation:
- `themes/academic/assets/js/academic-search.js` initializes `$.getJSON(search_config.indexURI, ...)` immediately when Fuse is present.
- `themes/academic/layouts/partials/site_js.html` publishes `/index.json` as the search index URI.
## Requested change
- Move index loading behind the search-open / first-query path.
- Cache the in-flight/completed request so opening search repeatedly does not refetch it.
- Preserve direct links such as `?q=term`: those should load the index and render results automatically.
- Show a useful failure state if the index cannot be loaded.
- Keep language-specific index splitting as a follow-up optimisation, not a prerequisite for this fix.
## Acceptance criteria
- A cold-load network trace on a normal content page has no `/index.json` request.
- The first search interaction makes exactly one request and returns results.
- Reopening search does not make another request.
- A direct `?q=term` URL still works.
- Existing search analytics/UI behaviour is unchanged.
Beitragsleitfaden
Bewertung
Dieses Issue wurde noch nicht bewertet.