Skip to content

Conversation

rschristian
Copy link
Member

@rschristian rschristian commented Aug 15, 2025

Instead of lazily loading Docsearch (which offers only a momentary delay in downloading the chunk as it's used in the header), let's lazily load it only upon intent to interact, i.e., upon focus, mouse over, touch start, etc. If they user interacts with the docsearch button prior to mount, we'll show a loading bar & trigger a click imperatively once it's loaded, getting around any "jank" issues where the user will need to submit another click/enter key (if tabbing), etc.

Cuts the initial JS load by about 47% or 28kb. Couple kbs less of CSS too, as that'll lazy load now as well.

@rschristian rschristian force-pushed the refactor/lazily-load-docsearch branch from 8a0dfb0 to 278bfb7 Compare August 16, 2025 02:21
Comment on lines -1 to +3
@import '@docsearch/css';

.DocSearch-Button {
display: flex;
justify-content: space-between;
Copy link
Member Author

Choose a reason for hiding this comment

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

The extra CSS in this file is to compensate for @docsearch/css no longer being here to build upon. Should look identical

@rschristian rschristian marked this pull request as ready for review August 16, 2025 03:37
@rschristian rschristian merged commit 49ccd4a into master Aug 16, 2025
5 checks passed
@rschristian rschristian deleted the refactor/lazily-load-docsearch branch August 16, 2025 16:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants