Move as much JavaScript as possible to a separate file