forrtproject / forrtproject/forrtproject.github.io

Lazy-load the global search index

Open
#861 0 comments 0 reactions 1 assignee Claimed by @LukasWallrich View on GitHub
enhancement needs-expert-review new website
Dominant language
HTML
Stars
42
Forks
33
Avg merge
2d 6h
Merged PRs (30d)
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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.