logoalt Hacker News

blixttoday at 5:19 AM0 repliesview on HN

The biggest performance bomb you can have in your code is a loop that does something like

    for (...) {
        el.style.height = `${something}px`;
        whatever.value = el.style.offsetHeight;
    }
This forces the browser to recalculate layout multiple times in a single frame. Separating layout changing code from measurement code will help a lot here (most frameworks out there have solved this so we don't have to be too concerned about it though).