improve compatibility in client side js, resolves #22