I’m using a modified version of the jQuery UI Autocomplete Combobox, as seen here:
http://jqueryui.com/demos/autocomplete/#combobox
For the sake of this question, let’s say I have exactly that code ^^^
When opening the combobox, either by clicking the button or focusing on the comboboxs text input, there is a large delay before showing the list of items. This delay gets noticeably larger when the select list has more options.
This delay doesn’t just occur the first time either, it happens every time.
As some of the select lists on this project are very large (hundreds and hundreds of items), the delay/browser freezing up is unacceptable.
Can anyone point me in the right direction to optimise this? Or even where the performance problem may be?
I believe the issue may be to do with the way the script shows the full list of items (does an autocomplete search for an empty string), is there another way to display all items? Perhaps I could build a one off case for displaying all items (as it is common to open the list before starting to type) that doesn’t do all the regex matching?
Here is a jsfiddle to fiddle with:
http://jsfiddle.net/9TaMu/
With the current combobox implementation, the full list is emptied and re-rendered every time you expand the dropdown. Also you are stuck with setting the minLength to 0, because it has to do an empty search to get the full list.
Here is my own implementation extending the autocomplete widget. In my tests it can handle lists of 5000 items pretty smoothly even on IE 7 and 8. It renders the full list just once, and reuses it whenever the dropdown button is clicked. This also removes the dependence of the option minLength = 0. It also works with arrays, and ajax as list source. Also if you have multiple large list, the widget initialization is added to a queue so it can run in the background, and not freeze the browser.