Javascript auto-complete

I’ve seen a number of questions on Stack Overflow wondering how to implement auto-complete in Javascript with large dictionaries. There are bad ideas (using jquery’s autocomplete with an enormous list of words embedded in the page), and there are people who have the right idea (do this in a web service), but no ready-to-use solutions. So I built one.

The basic architecture here is a small bit of jQuery code that calls out to a web service written in C with the FastCGI library. The C program uses an implementation of DJB’s critbit tries for storage of the dictionary, which is fast enough to make response times almost instantaneous, and because it’s a long-running process, there is no startup cost for reading the dictionary from disk for each request.