Refactor javascript for production.