rust-lang / rust-lang/mdBook

Making searchindex.js smaller

Open
#2,737 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

C-enhancement
Dominant language
Rust
Stars
22.2k
Forks
1.9k
PR merge metrics
PR metrics pending

Description

Problem

The file searchindex.js used for searching is quite big. e.g. for one of my books it is 2,052,190 bytes.

Proposed Solution

Two ideas:

  1. The {"body":27,"breadcrumbs":6,"title":2} appears quite a few times in the data. We might change that mapping to an array [27, 6, 12].
  2. The whole JSON might be minified before we store it in the js file.
Notes

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading searchindex.js and identify how repeated field mappings and JSON formatting contribute to its size. Compare the proposed array representation and minified output, then verify that the generated index remains usable for searching while being smaller.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, rust
Domain
performance, search
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.