forrtproject / forrtproject/forrtproject.github.io

Lazy-load the global search index

Ouverte
#861 0 commentaires 0 réactions 1 personne assignée Réclamée par @LukasWallrich Voir sur GitHub
enhancement needs-expert-review new website
Langage dominant
HTML
Étoiles
42
Forks
33
Merge moyen
2 j 6 h
PR mergées (30 j)
19

Description

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

Guide de contribution

Ouvrir le guide de contribution

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.