javascript - Minimise "Forced reflow" - Stack Overflow

TD;DRI spend some time tracking the performance of our app, which implements highcharts. I figured out,

TD;DR

I spend some time tracking the performance of our app, which implements highcharts. I figured out, that some function like getBBox() do trigger "Forced reflow" quite often.

If you look at this list What forces layout / reflow, the things that trigger a reflow is very long.

My Question:

Are there alternative for at least some of the listed properties (espacially offsetWidth/offsetHeight), that do NOT trigger a reflow?

TD;DR

I spend some time tracking the performance of our app, which implements highcharts. I figured out, that some function like getBBox() do trigger "Forced reflow" quite often.

If you look at this list What forces layout / reflow, the things that trigger a reflow is very long.

My Question:

Are there alternative for at least some of the listed properties (espacially offsetWidth/offsetHeight), that do NOT trigger a reflow?

Share Improve this question asked Oct 24, 2017 at 8:38 scipperscipper 3,1633 gold badges26 silver badges43 bronze badges 3
  • 1 In most scenarios, if you want a better performance on manipulating DOM elements, you should separate it into a new layer and use only the hardware accelerated transformations which do not trigger any reflow of the entire page. – Derek 朕會功夫 Commented Oct 24, 2017 at 8:41
  • @Derek朕會功夫 Very nice article. I tried to move one expensive element to a new layer, and it does reduce the reflow occurrences. The impact was not that massive, but it's a start. Thanks! – scipper Commented Oct 24, 2017 at 10:54
  • You can switch to canvas charts. – woxxom Commented Oct 24, 2017 at 16:48
Add a ment  | 

1 Answer 1

Reset to default 7

Are you familiar with docs like Avoid forced synchronous layouts? The main idea is to do all of your read operations before your write operations that change the layout of an element. As long as you follow that principle it's less important what properties you use. Although of course it's always a good idea to use properties that do as little work as possible.

.High-Performance Animations is a good resource on what properties are efficient though. This relates to the layers approach that Derek mentioned.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745348637a4623692.html

相关推荐

  • javascript - Minimise "Forced reflow" - Stack Overflow

    TD;DRI spend some time tracking the performance of our app, which implements highcharts. I figured out,

    8小时前
    40

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信