Refactor js on news site