Move JavaScript to js file