Client JavaScript rewrite (Part. toScore & toBG)