Refactor script.js.