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

Use JSON.parse to load searchData #1825

Closed
dragomirtitian opened this issue Dec 21, 2021 · 1 comment · Fixed by #1826
Closed

Use JSON.parse to load searchData #1825

dragomirtitian opened this issue Dec 21, 2021 · 1 comment · Fixed by #1826
Labels
bug Functionality does not match expectation

Comments

@dragomirtitian
Copy link
Collaborator

Search terms

JSON.parse, load, search, performance, searchData

Expected Behavior

TypeDoc loads search index before the user has a chance to start typing in the search bar

Actual Behavior

For large indexes (we have a 17MB one) loading the index takes up to 6-7s. Most of this time is spent in parsing and loading the object literal.

Suggestion

Use JSON.parse("<index data>") instead to load the index. JSON parsing is much faster than JS parsing as the grammar is simpler, and when the index is large the difference is quite big.

Steps to reproduce the bug

It's hard to reproduce this without actually sharing our existing index. If needed I can create a dummy repository

Environment

  • Typedoc version: 0.21.6
  • TypeScript version: 4.3.5
  • Node.js version: 14
  • OS: Windows 10
@dragomirtitian dragomirtitian added the bug Functionality does not match expectation label Dec 21, 2021
@Gerrit0
Copy link
Collaborator

Gerrit0 commented Jan 3, 2022

Sounds reasonable to me 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Functionality does not match expectation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants