Reflow/Layout performance for large application

前端 未结 1 1356
旧巷少年郎
旧巷少年郎 2021-02-11 03:40

I am using GWT to build a HTML application where the performance is correct in general.

Sometimes, it can load many objects in the DOM and the application becomes slow.

相关标签:
1条回答
  • 2021-02-11 04:19

    I finally solve my problem : getBoundingClientRect was triggering a whole layout event in the application, which was taking many times through heavy CSS rules.

    In fact, layout time is not directly proportional to the number of elements in the DOM. You could draw hundred thousands of them with light style and layout will take only 2ms.

    In my case, I had two CSS selectors and a background image which were matching hundred thousands of DOM elements, and that was consuming a huge amount of time during layout. By simply removing those CSS rules, I reduce the layout time from 900ms to 2ms.

    0 讨论(0)
提交回复
热议问题