JS performance improvement