Batch your DOM changes, especially when updating styles
https://www.linkedin.com/pulse/25-techniques-javascript-performance-optimization-steven-de-salas
When making calls to modify DOM make sure you batch them up so as to avoid repeated screen rendering, for example when applying styling changes. The ideal approach here is to make many styling changes in one go by adding or removing a class, rather than apply each individual style separately. This is because every DOM change prompts the browser to re-render the whole UI using the boxing model. If you need to move an item across the page using X+Y coordinates, make sure that these two are applied at the same time rather than separately.
2 months ago
User agent:
Mozilla/5.0 (iPhone; CPU iPhone OS 17_6_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.6 Mobile/15E148 Safari/604.1
Test name
Executions per second
Using multiple calls to host objects (DOM)
50402.7 Ops/sec
Using batching - grouping multiple DOM manipulations together