Optimize javascript by caching jquery selector results.