-
Notifications
You must be signed in to change notification settings - Fork 187
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Single style element vs. style per component class #45
Comments
A problem I can see with aphrodite's approach is that writes to the style element will become slower with every added rule. If at some point, when all styles are rendered, lets say 10kb of styles, I add one more rule, it will create a CSS string with all previous styles + the new one and insert it into style element. Correct me if I am wrong. The problem is not just parsing of that CSS string, but also that CSSRule instances are not going to be reused. |
The main reason that we use a single I think you are correct, the browser probably has to re-parse the whole CSS string. We add new As far as comparing to Hopefully this answers your questions, feel free to re-open if I missed something. |
Thank you for your answer. Yes I have heard of a limit in IE9, that is bad. JSS needs a legacy rendering mode for IE9.
This is probably not much of profit when rendering at runtime. The moment user clicks a button and you render an element that uses style rule which is not rendered, you are doing the whole overhead of rerendering the entire style sheet just to add for e.g. one rule to the style sheet. This is post probably performance drawback than optimization. However I agree that server-side rendering will benefit from this. As it renders just one state for each component. I am very curious how much bandwidth this can safe! Can you generate some stats on the code base you have?
Of course they will if you overwrite the entire sheet. I saw this jsperf bench: http://jsperf.com/append-to-style-vs-create-new-style
|
I don't have these offhand, but I'll look into it. Unfortunately, most of the things that we're using aphrodite styles for were written from scratch with them, so we don't have anything to compare that to.
That API looks really interesting! That could definitely help with performance, I'll check it out. |
You could log the rules used during rendering and then log entire styles objects used during the same rendering. Like turn on and off the cherry picking of rules and compare the sizes. |
Also you might be interested in cssinjs/jss#204 |
I wonder if you guys did any performance comparison of this 2 different approaches:
The one of aphrodite (as far as I understand):
css()
functioncss()
calls are buffered and rendered byasap
flushvs.
The one of jss or better to say react-jss:
The text was updated successfully, but these errors were encountered: