-
Notifications
You must be signed in to change notification settings - Fork 483
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
Universal selectors are not slow #620
Comments
@pugsiman Please provide some more information and/or sources. |
http://www.paulirish.com/2012/box-sizing-border-box-ftw/ |
I think the idea is currently that you can use a star selector if you know what you're doing, as an exception. In general, it's still a good rule. @stubbornella can probably comment on your first source, which links to her entry at http://calendar.perfplanet.com/2011/css-selector-performance-has-changed-for-the-better/ . |
No, the idea is that bad performance from star selector is the exception. You should read the sources. |
I did. I think if you are 100% certain that you want to apply a certain property to everything, then it's fine. The rule is mostly against code like:
in my opinion. The rules are not absolute and you're free to disable the rule via one of the many possibilities to exclude rules per line or file or even disable entire rules. So in general the rule makes sense (like not allowing !important), but there are circumstances where the rule doesnt apply. Like in the examples in your sources. Slight note: I think it's a pity that the author of one of the sources isn't sharing the absolute values for his experiment. It would be useful information. Of course it will differ based on the chosen property. I think box-sizing and setting meta-data for transitions won't have a big impact, but setting rounded corners or gradients that way would probably have a big impact. Let's see if we can get more input from others. Edit: I just checked and I disagree with the way he's testing. Continuous layout/render/paint performance, for example while scrolling, can't be properly evaluated with a JS-based test like that. |
Right, but using it the way you mentioned (and Paul's) seems, to me, to be the exception. Most people use the universal selector as means for normalization, and not for specific styling. |
Can you propose a way to make the current rule smarter? Maybe we can allow a specific subset of commands to * but only if * is the only selector of that rule? If not, I would suggest to just disable it for your use case. Other people might depend on this rule for their use-cases. |
That's a good idea, anything coupled with the universal selector should raise a warning. In of itself, it shouldn't. |
Maybe. That would mean a big change to an existing rule and I don't feel that your use case is worth that at this moment in time. I think your best bet is to disable this check for your use case, or use the just-merged "csslint allow" directive to ignore errors of a predefined rule on a specific line. If others agree with your point, we can revisit this topic. A pull request for the "updated * rule" would of course be much appreciated. |
See #271 for another point for the universal selector rule. |
You should drop the warnings of universal selectors being slow. This was debunked for a while now, and except maybe a few select cases, it is generally OK.
The text was updated successfully, but these errors were encountered: