Moving more code into separate js file