Extract JavaScript into its own file