sayeed910
sayeed910

Reputation: 313

serverside vs clientside autocomplete

The title somewhat says it all.

I have a text-field where i want to have autocomplete. Lets say it is a products search field needed for an e-commerce solution. The products are in the database. Now I can either load the list using ajax when the user does a key-press on the text-field(maybe use autocomplete from jquery). I can also load all the products before page loading from the database and pass it as a drop-down menu(select2 maybe). What I want to know is which approach is appropriate. Some characteristics of my situation are:

  1. The user will always at least search for 5 products.
  2. The amount of products maybe > 10000.

I read an article from this place which suggests I use server-side solution. However, I would like to know some more opinions regarding this issue.

Upvotes: 2

Views: 525

Answers (1)

Alex Paven
Alex Paven

Reputation: 5549

It really depends on what data you load for the products; if it's just the name (and you don't have very long names), 10000 is around the limit I'd personally consider, and you could load them up-front and simplify everything else (unless the product list is expected to grow a lot).

The alternative means taking greater care of how you issue the requests; some common best practices are to start searching only after at least two characters are entered, and to not issue requests on each keypress, but rather wait until the user pauses for a number of milliseconds; that way, you don't flood your server with requests that are already useless by the time they return. This technique is usually called debounce/debouncing. Of course, if you use a UI library that has an autocomplete component, this may be handled for you by the component.

Upvotes: 2

Related Questions