christian-fei / Simple-Jekyll-Search

A JavaScript library to add search functionality to any Jekyll blog.
https://christian-fei.github.io/Simple-Jekyll-Search/
MIT License
1.34k stars 203 forks source link

Add a way to limit how many times the search function can be executed over a given time window (debouncing) #161

Closed marcwrobel closed 3 years ago

marcwrobel commented 3 years ago

Add the necessary code and option for limiting how many times the search function can be executed over a given time window. The technique used to achieve this goal is called "Debouncing" (see https://www.telerik.com/blogs/debouncing-and-throttling-in-javascript) and the debouce time is controlled by a new option : debounceTime.

Supporting debouncing is especially useful to improve the user experience when searching over a large dataset (either with rare terms ou because the number of posts to display is large). If no debounceTime is provided a search will be triggered on each keystroke (the behavior before this option was introduced).

christian-fei commented 3 years ago

🙌 thank you!