Skip to content

Commit 5fa7b6c

Browse files
committed
optimize search indexing with delayed background processing
1 parent e00f6ac commit 5fa7b6c

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

src/components/store.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,9 @@ export async function preloadFrontmatter() {
9696
updateNavigationTitle(fm.path, fm.title);
9797
}
9898

99-
// Build search index in the background — don't block page rendering.
100-
// Each page's raw MDX is fetched individually, so for large sites this
101-
// can be hundreds of requests. We batch them to avoid overwhelming the
102-
// browser's connection pool.
103-
addPreloadedContentToSearch();
99+
// Build search index in the background after the page has fully rendered.
100+
// Delay avoids competing with the route chunk for network connections.
101+
setTimeout(() => addPreloadedContentToSearch(), 2000);
104102
}
105103
}
106104
} catch (error) {

0 commit comments

Comments
 (0)