Split javascript file into init, run and apiCall