6 ms·
The biggest performance bomb you can have in your code is a loop that does something like for (...) { el.style.height = `${something}px`; w
by blixt 3mo ago
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).
- imtringued 3mo agoThis is true, but a much more common reason is that you have a self growing textarea and Firefox didn't support field-sizing: content until recently, so you had to let JS resize the textarea on every keypress.
- giancarlostoro 3mo agoI miss Firefox Quantum that effort should have continued, stuff like this makes for great candidates for that initiative to resolve.
- ErroneousBosh 3mo ago[dead]
- mananaysiempre 3mo agoOr as Andreas Kling (jokingly) put it[1]: “STOP INTERLEAVING STYLE CHANGES AND LAYOUT METRIC QUERIES ASSHOLE”. [1] https://nitter.net/awesomekling/status/2021932080742142056 https://nitter.net/awesomekling/status/2021932080742142056