What is the Most Performant way of hiding/showing a group of elements inside of a webpage?
I’m making a web application, in which let’s say at a certain moment I have 100 editor panels with 10 rows each (row - which consist of a label at left and a data-field on right, such as input field, color picker, image picker, and etc.)
And at a moment, only 1 of the editor panel is workable, and all else is hidden.
Regarding this imagined stress case, what should be the most performant way of showing/hiding, or better said - keeping the hidden panels not drag down page performance?
I was wondering at the use of having only 1 panel created with js/jquery, and removing or deleting the one not in need. But I must keep the editor panels’ current state, and not lost. Thought I’d go for creating a nested array or tons of variables to store every panel’s row’s current data state, but that would be less feasible.
Hence, any inputs by knowledgeable people here much appreciated
I had read this article on Sitepoint before: https://www.sitepoint.com/hide-elements-in-css/ . According to which,
display: nonehas been the favorite solution to hide elements for many years, but it’s been superseded by more flexible, animatable options. It’s still valid, but perhaps only when you want to permanently hide content from all users.
opacityare better choices when considering performance.
The panels in my app would be better off having a hiding and showing animation, to show some smoothness. Hence I wonder, if keeping elements hidden with
opacity properties are good for performance, I could use them for animations too. But ofcourse, I can animate them with those properties and still use “a better way to keep good performance”, which I’m seeking to know more