Group search scripts under requirejs.

Simplify a bit the search javascript by using require and removing some not necessary stuff.