This project has moved and is read-only. For the latest updates, please go here.

SPAutocomplete performance trick

Feb 5, 2012 at 9:31 PM
Edited Feb 5, 2012 at 9:45 PM

Hi Marc,

I am a big fan of your jQuery scripts :).

So, I have been using your "SPAutocomplete" a lot and I realized that for every keystroke it makes a web service call with the new filter value.

My suggestions is, once it pulls the records for the first time, all subsequent filters (key-strokes) are technically going to be a subset of your original result-set, so why not just store the original result-set at client side and keep applying the subsequent filters on it as the user types more and more characters? :)

I have already implemented it and it's working great (in my opinion :)). Of course it will eat up a little more RAM on the client machine but I think the performance boost is surely worth the price, plus client machines are getting more and more powerful (CPU+RAM) every day, aren't they? :).

So internally only the first population takes the performance hit due to making an actual w/s call but all subsequent filtering is done on this result-set (which is actually just a javascript array) and so is very quick.

I make web service call only when the # of chars in the textbox are equal to the numChars value. That way if the person removes the whole filter and starts all over again, it should NOT apply the filter on the previous result-set :).

There is one more thing I would like to add to it...

It makes w/s calls even if you press the arrow keys :). I think we should check the ASCII of the key pressed to skip all unwanted w/s calls, what say? :)

What do you think about these? Do you wish to implement any/both of these in your next release? :) :)

Feb 6, 2012 at 2:04 PM


All valid points. I built the function and put it out there quite a while ago, but I rarely get any questions about it, so I've assumed that it's getting little use. The survey I did last year also indicated that it's not a frequently used function. Because of this, I haven't done much with it.

If you have already implemented the fixes you outline, I'd love to have them for the next release.