I made an autocomplete input box of every town, city and village in the UK. Yes, every single one. The load times are painful so is there a way to reduce that?

Here is a sample:

<input type="text" id="location" name="locations" placeholder="Edinburgh, Belfast, Cardiff, London">
$( function() {
    var availableTags = [
      "Abbots Bromley",
      "Abbots Leigh",
      source: availableTags

Here is a JSFiddle with the entire list, which has 7726 items.

  • \$\begingroup\$ I think you should post it in stackoverflow, because you are seeking for hekp and not Code review... \$\endgroup\$ Commented Nov 30, 2016 at 17:04
  • \$\begingroup\$ Yeah you could be right, I had assumed because it works as intended it wouldn't the correct place for it, I thought it might be a performance issue that could be improved upon \$\endgroup\$
    – Jon Snow
    Commented Nov 30, 2016 at 17:17
  • 1
    \$\begingroup\$ On an aside, the edits made, helpedme understand how to ask a question in a more cohesive manner, thanks \$\endgroup\$
    – Jon Snow
    Commented Nov 30, 2016 at 18:55

1 Answer 1


You can improve performance by using autocomplete function with this options:

$( "#location" ).autocomplete({
      source: availableTags,
      delay: 0,
      minLength: 2,

This library has a 300 ms delay by default. So setting delay to 0 disables it. minLength is for loading the matches after the users typed at least 2 chars, I don't think there is a point to load them when you have only 1 character.

Good luck

  • \$\begingroup\$ Very good answer \$\endgroup\$
    – Tolani
    Commented Dec 1, 2016 at 22:56
  • \$\begingroup\$ I don't agree with removing the delay (also known as debounce). It helps skip searches when you quickly type in more letters, which improve performance. If performance is the main focus, you should keep it. \$\endgroup\$
    – Kruga
    Commented Dec 2, 2016 at 10:04
  • \$\begingroup\$ At least, it can be decreased I think. \$\endgroup\$
    – Dan Cantir
    Commented Feb 18, 2017 at 15:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.