split out js file into client, server and lib folders