-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Explore request timing optimizations for typeahead search and username/tag autocompletion #3472
Comments
Hi, I'd be interested in working on this - would you prefer to format it as an FTO first? |
Hi! This may be a relatively complex one that would need to be solved in a few parts. But the basic |
Hi @jywarren . This is just pure speculation, but I searched around and found the avg typing speed is about 40 wpm and given about 5 characters per word, there will be 1 character around ~300 ms. So maybe we could set the delay to 350 ms so that it will not repeatedly search while the user is typing and won't make the user wait long after they are done? I will go ahead and post an FTO for this 👍 . If you would like for me to make any changes, just let me know 😄 . |
thanks for doing this! This is merged. I think we could continue to refine this using different strategies like the above debounce. Also perhaps looking at: https://lodash.com/docs/4.17.10#debounce https://css-tricks.com/debouncing-throttling-explained-examples/ https://davidwalsh.name/javascript-debounce-function @milaaraujo @sagarpreet-chadha just a note because I think i've mentioned debounce to both of you at different points, the last link above is pretty good explanation for this strategy! |
Moving this analysis here to help explain the bottlenecks in typeahead: Note how many requests go out -- i think we can change the settings on the typeahead to refine this. See a gif: Also note it's sending lots of requests where So we might still pursue:
This would apply to both the typeahead search code (using Bootstrap Typeahead): https://github.com/publiclab/plots2/blob/master/app/assets/javascripts/restful_typeahead.js And the comment form autocompletion code (using At.js): https://github.com/publiclab/plots2/blob/master/app/assets/javascripts/atwho_autocomplete.js |
Our nice typeahead search is SUPER! (Thanks @milaaraujo @stefannibrasil !!)
I think we could speed it up a bit and also have it be a little less jittery by using a throttling strategy.
See how when you type the word "balloon" it makes 5 different queries?
We're using Bootstrap Typeahead: https://github.com/bassjobsen/Bootstrap-3-Typeahead to run this code.
For starters, we can set the
minLength
anddelay
to 3 and 1, respectively, so it only starts searching after 3 characters are input, and only sends one request per second. This should slow things down a good bit (but test it out locally to see if it works for you!)After merging those changes, we could explore more sophisticated "debounce" strategy -- https://davidwalsh.name/javascript-debounce-function
The text was updated successfully, but these errors were encountered: