Skip to content

Use JSON.parse to load searchData #1825

@dragomirtitian

Description

@dragomirtitian

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions