Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

And it's especially bad if you interleave them all:

  var heights = lotsOfElements.map(function(el){
    el.classList.add('ok');
    return el.clientHeight;
  });
Better is to batch the DOM updates and reads, where you can:

  lotsOfElements.forEach(function(el){
    el.classList.add('ok');
  });
  var heights = lotsOfElements.map(function(el){
   return el.clientHeight;
  });


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: