Dynamically calculated properties that take on many possible values? Garbage collection? #886
-
It seems that if I have a property value that might change between many different numeric values, e.g. "123px" one minute, "137px" the next... Fela will create a new stylesheet rule each time, potentially leading to hundreds or thousands of such rules. I don't see anything in the docs saying, "By the way, don't do that." Even in milder situations, Fela's stylesheet could grow quite large. Rules are never removed, correct? Is there anything I'm missing? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Heyhey! Yes, highly dynamic values will create a lot of unique rules that are added immediately (which eventually leads to many style updates), but we use We don't (can't) remove rules at any time, since we have don't track (this would kill the performance) the occurrence of each rule, so we don't know if it is used anywhere else. |
Beta Was this translation helpful? Give feedback.
Heyhey!
Yes, highly dynamic values will create a lot of unique rules that are added immediately (which eventually leads to many style updates), but we use
insertRule
to do that, so the overhead is minimal. Yet, for values that change very often e.g. when animating values, I would recommend to use inline styles instead since they're more suited for this specific situation. Actually, this is true for every CSS in JS library, while Fela at least only renders the changed declaration and not the full style object.With the atomic CSS approach, the size of your stylesheets already is way smaller compared to traditional solutions, but since you have a lot of uneven and most likely never reused d…