rust-lang / mdBook

Create book from markdown files. Like Gitbook but implemented in Rust
https://rust-lang.github.io/mdBook/
Mozilla Public License 2.0
17.84k stars 1.62k forks source link

de-duplicate the search index #2425

Open nick1udwig opened 1 month ago

nick1udwig commented 1 month ago

Currently, the search index is duplicated in searchindex.js and searchindex.json. It seems the reason for the duplication is that the .json allows for async loading via fetch() and the .js provides a fallback in case CORS causes issues with the fetch().

The problem with having the duplicated index is that for large books, the index becomes quite large (2.5MB for my company's book!). It would be nice if the index didn't have to be duplicated.

This PR removes searchindex.json from the site output. It replicates the async functionality by reading in the searchindex.js file and parsing out the JSON within. The fallback remains unchanged.

SichangHe commented 1 week ago

Related: #2403.