forrtproject / forrtproject/forrtproject.github.io

Lazy-load the global search index

Abierto
#861 0 comentarios 0 reacciones 1 asignado Reclamado por @LukasWallrich Ver en GitHub
enhancement needs-expert-review new website
Lenguaje dominante
HTML
Estrellas
42
Forks
33
Merge medio
2 d 6 h
PR fusionados (30 d)
19

Descripción

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

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.