Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only load searchindex when needed #2553

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

GuillaumeGomez
Copy link
Member

@GuillaumeGomez GuillaumeGomez commented Feb 20, 2025

First commit comes from #2552.

This PR makes it so that the searchindex.js file is only loaded when the user arrives on a page with ?search= in the URL or if the user opens the search.

cc @notriddle

@rustbot rustbot added the S-waiting-on-review Status: waiting on a review label Feb 20, 2025
@notriddle
Copy link
Contributor

If you're going to mess with the search engine, can you also write some gui tests that exercise it?

@GuillaumeGomez
Copy link
Member Author

Very good point.

@GuillaumeGomez
Copy link
Member Author

Added the GUI test. :)

@@ -2,9 +2,6 @@
// an iframe (because of JS disabled).
// Regression test for <https://github.com/rust-lang/mdBook/issues/2528>.

// We disable the requests checks because `searchindex.json` will always fail
// locally.
fail-on-request-error: false
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great! 👍

@GuillaumeGomez
Copy link
Member Author

When the JS is being retrieved, there is now a spinner and the input is not disabled anymore:

image

@GuillaumeGomez GuillaumeGomez requested a review from ehuss February 21, 2025 22:14
@GuillaumeGomez
Copy link
Member Author

Rebased and fixed merge conflict.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: waiting on a review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants