I’m building an Ionic app. The app contains an array of 20k “word” objects with the word and pronunciation. This data is all local and is used via a service.
There’s a search page with a search input that on keydown makes a new search request and updates the “DOM.” The time it takes to run my search function takes a few seconds depending on the search, so the user can’t even type multiple characters without delay.
I’ve tried just running the function without the DOM aspect and it’s still slow.
I’ve even tried rewriting my .filter() function as a for loop with various limits for the number of results, but if there isn’t a match, the whole 20k array of items will be searched.
Is there a faster way to make this search function, or do I just need to reduce my dataset? Is there a good tutorial for something like this?