-
-
Notifications
You must be signed in to change notification settings - Fork 184
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
[Benchmark] DOM rendering performance #3
Comments
@rofrischmann FWIW: https://bugs.chromium.org/p/chromium/issues/detail?id=387952#c6 -- and it's tagged as "WontFix" |
I see. So what you're saying is not to use insertRule if possible? |
@rofrischmann Using that API severely limits dev tools usage, can't even toggle the properties in chrome: |
I've created a small benchmark to generally check the speed (https://gist.github.com/rofrischmann/15073c4297e0bbd6e0732e4903655d7c). [Log] Running 10 times...
[Debug] insertRule: 0.391ms
[Debug] concatTextContent: 1.055ms
[Debug] overwriteTextContent: 0.970ms
[Log] Running 100 times...
[Debug] insertRule: 0.338ms
[Debug] concatTextContent: 17.685ms
[Debug] overwriteTextContent: 18.403ms
[Log] Running 1000 times...
[Debug] insertRule: 3.450ms
[Debug] concatTextContent: 857.059ms
[Debug] overwriteTextContent: 791.947ms
[Log] Running 10000 times...
[Debug] insertRule: 49.079ms
[Debug] concatTextContent: 92909.438ms
[Debug] overwriteTextContent: 85547.511ms Well, we're talking about milliseconds, but as we know it we should consider using |
@rofrischmann Thanks for running those benchmarks, very interesting! Couple of quick Qs:
|
What do you think of your approach here vs your approach in |
Well yeah, I am experimenting since I started with Look and came up with the solution that generating CSS still is the best way, but needs to be more dynamic. Actually I did not test it with HMR or time travel, but might do this. HMR should work I guess, but for time travel we might need to implement another middleware (which is also one of the cool new features that Look does not provided that easy). I guess you will better understand what I mean when the React bindings are out. It doesn't really have any special fancy API it just works :p I will update this comment at home to answer all your questions correctly. Is there a special specificity problem you are interested in? |
Thanks for the detailed response! You have reflected some of my own fears about Here's some pseudocode demonstrating the specificity question/concern: // assume `classes` holds fela classNames for this react component
const Button = (props) => (
<button className=${classnames(classes.button, props.className)}>
{props.children}
</button>
); // assume `classes` holds fela classNames for this react component
const MyBox = () => (
<div className={classes.base}>
<Button className={classes.button}>Hello</Button>
</div>
); How does fela handle the specificity issue there when overriding styles via passing another classname created by fela? |
@rofrischmann Could we use |
@nathanmarks That seems to be an example I did not consider to handle actually, maybe I got the term specificity wrong at all. Do you have any example of libs/ideas that handle this case wisely? @oliviertassinari Yeah, I was think about that. I already eliminate all NODE_ENV != 'production' paths while building, so that should not be a problem. I though might get too complex. An alternative would be to just implement a simple middleware that handle modifies the change event action. Let me know what you think of both ways. @nathanmarks @oliviertassinari Feel free to join me on Gitter for further chatting :P |
@rofrischmann I'll find you on there |
In order to get the best (DOM) rendering performance possible, we should generate some basic benchmark to test different methods of adding a new ruleset to a CSSStyleSheet.
Methods
node.sheet.insertRule(rule)
node.textContent = updatedCSS
node.textContent += rule
The text was updated successfully, but these errors were encountered: