toolkit icon indicating copy to clipboard operation
toolkit copied to clipboard

Generate less DOM nodes

Open arneg opened this issue 9 years ago • 3 comments

In many widgets like circular, DOM nodes are created but are often left empty, like markers, dots, etc. Create those nodes dynamically when they are needed. They increase the size of the DOM and thereby the cost of relayouts.

arneg avatar Apr 17 '16 11:04 arneg

Here are some statistics of the 64 channel demo. Whats measured here is a timeline profile for setting a random value to a knob 100 times. The difference with the measurements is number of strips and number of pages.

Safari (MacBook Pro)

1 Strip and 1 Page

1s1p

8 Strips and 1 Page

8s1p

8 Strips and 8 Pages

8s8p

8 Strips and 8 Pages (all pages preloaded)

8s8p nd

8 Strips and 8 Pages (no preload, no DOM)

pages removed from dom, instead of 'display:none' 8s8p nd np

8 Strips and 8 Pages (no preload)

8s8p np

Chrome (MacBook Pro)

1 Strip and 1 Page

c 1s1p

8 Strips and 1 Page

c 8s1p

8 Strips and 8 Pages

c 8s8p 2

8 Strips and 8 Pages (no DOM)

c 8s8p nd

8 Strips and 8 Pages (no preload)

c 8s8p np

8 Strips and 8 Pages (no preload, no DOM)

c 8s8p np nd

Firefox (MacBook Pro)

1 Strip and 1 Page

f 1s1p

8 Strips and 1 Page

f 8s1p

8 Strips and 8 Pages

f 8s8p

8 Strips and 8 Pages (no DOM)

f 8s8p nd

8 Strips and 8 Pages (no DOM, no preload)

f 8s8p nd np

8 Strips and 8 Pages (no preload)

f 8s8p np

Microsoft Edge

legende

1 Strip 1 Page

e 1s1p

8 Strips 1 Page

e 8s1p

8 Strips 8 Pages

e 8s8p

8 Strips 8 Pages (no DOM)

e 8s8p nd

8 Strips 8 Pages (no preload)

e 8s8p np

Safari (iPad)

1 Strip 1 Page

ik 1s1p

8 Strips 1 Page

ik 8s1p

8 Strips 8 Page

ik 8s8p

8 Strips 8 Page (no preload)

ik 8s8p np

arneg avatar Apr 17 '16 12:04 arneg

As a comparison a similar benchmark with one levelmeter, which uses a canvas does not touch the DOM.

Safari (MacBook Pro)

1 Strip 1 Page

fd 1s1p

8 Strips 1 Page

fd 8s1p

8 Strips 8 Pages (no preload)

fd 8s8p

8 Strips 8 Pages

fd 8s8p preload

arneg avatar Apr 17 '16 22:04 arneg

I guess best way to fix is to still create the nodes but not to add them to the DOM if unused - or remove them from the DOM if emptied. Those nodes are an inherent part of a widget and should be available anytime - whether or not currently added to the DOM.

boomshop avatar Sep 23 '16 21:09 boomshop