Unify js code