O'Reilly logo

Instant typeahead.js by Toby Osbourn

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Preloading JSON (Should know)

One of the really useful things about typeahead.js is that it allows you to preload a JSON file into your lookups. Having a file that you can keep up-to-date as part of another process means that you don't have to worry about your database getting hit every time someone uses a lookup.

Another benefit of preloading JSON is that when you have a lot of data, it is good to have it stored in a file and not being loaded in the JavaScript like we did with our first recipe.

With that said, in this recipe, we will find out how to add a JSON file into the project and get typeahead.js working with it.

Getting ready

We will need all the same things that we needed for our last recipe, plus a JSON file, which we will make separately ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required