Refactor Javascript.