Emergic: Rajesh Jain's Blog

Emergic: Rajesh Jain's Blog header image 2

How Google Suggest Works

December 14th, 2004 · No Comments

Joel Spolsky points to a Rob Whelan post about Google Suggest.

Joel: “It’s one of the first prominent uses I’ve seen of the XmlHttpRequest technique of going back to the web server for more data while the user interacts with a page.”

Rob writes:

The source for the page is quite simple; most of the work happens in a condensed JavaScript library [google.com]. Not easy reading (note the word “condensed” above, meaning function and variable names are 1 or 2 chars, and all extra whitespace was removed…), but it’s actually pretty straightforward.

It disables your browser’s autocomplete on that textfield (for obvious reasons). Then it basically just defines a hidden div for that auto-complete dropdown (variations on this depending on browser… frickin’ incompatibilities).

Each time you type a character, it populates that div body with the results of a quick, tiny query back to Google. It’s NOT running the search for you; it’s hitting (I assume) a simple, probably totally in-memory list of the most popular searches and number of results. That’s how it can be so quick a response — the lookup on their end is super-minimal, and the data to be transferred is probably less than 1k each time.

Cool. Nice concept, nice execution. And one of those nice “only obvious in hindsight” additions.

Tags: Software

0 responses so far ↓

  • There are no comments yet...Kick things off by filling out the form below.

Leave a Comment