Splitting up the client side JavaScript