optimize client-side js and add post function in server-side js