Move JavaScript into .js file