refactor client side scripts