forrtproject / forrtproject/forrtproject.github.io

Lazy-load the global search index

Aperta
#861 0 commenti 0 reazioni 1 assegnatario Rivendicata da @LukasWallrich Vedi su GitHub
enhancement needs-expert-review new website
Lingua principale
HTML
Stelle
42
Fork
33
Merge medio
2g 6h
PR unite (30g)
19

Descrizione

## 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.

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.