Highlighting Search Terms with Javascript (Why you shouldn't)

by Charles Miller on June 21, 2004

One trend that's been wandering casually around the Internet lately has been the use of Javascript to highlight words in a page, if you visit that page via a Google search.

Like many of these web-tricks, it was interesting and 'neat' at first, but now I think its 15 minutes is up, and can we please quietly pack that script away and move on to something else?

The benefit of search-term highlighting is that it allows you to see where in a document the match occurred, which may sometimes be hard to spot.

The practical result, however, is different. It's very rare that I ask Google to give me a page that occasionally mentions the terms I am searching for. If it does, then Google is either not doing its job, or it's a really obscure search. What I usually want (and end up with) is a page that is largely about the terms I am searching for.

Even if I'm searching for something really specific that might only be mentioned in one section of a document, I'm probably going to have used several search terms that occur all the way through the page, and then added the specific, narrowing term on the end.

Which means, from experience, that these Javascript-enhanced pages light up like a Christmas tree.

The effect of the highlighting is to completely disrupt the flow of the page. The highlighted terms are dotted pretty evenly through the page (making having your eyes drawn to their location pointless), and the highlighting is usually more colourful and 'interesting' to your eyes than the page's headings, which might be more useful in locating the precise information you were after.

Previously: I Love Postgres

Next: They're Multiplying...