JS performance : Duplicate elements