Refactor JavaScript to use AMD modules for each view