Move JavaScript into files when possible