Slight refactor of client-side js for consistency --skip-ci