Skip to content
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

Closed
pugsiman opened this issue Oct 19, 2015 · 10 comments
Closed

Universal selectors are not slow #620

pugsiman opened this issue Oct 19, 2015 · 10 comments

Comments

@pugsiman
Copy link

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.

@frvge
Copy link
Contributor

frvge commented Jan 23, 2016

@pugsiman Please provide some more information and/or sources.

@pugsiman
Copy link
Author

@frvge
Copy link
Contributor

frvge commented Jan 25, 2016

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/ .

@pugsiman
Copy link
Author

No, the idea is that bad performance from star selector is the exception. You should read the sources.

@frvge
Copy link
Contributor

frvge commented Jan 27, 2016

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:

.menu * {
  width: 100px;
}

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.

@pugsiman
Copy link
Author

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.

@frvge
Copy link
Contributor

frvge commented Feb 3, 2016

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.

@pugsiman
Copy link
Author

pugsiman commented Feb 7, 2016

That's a good idea, anything coupled with the universal selector should raise a warning. In of itself, it shouldn't.

@frvge
Copy link
Contributor

frvge commented Feb 9, 2016

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.

@frvge frvge closed this as completed Feb 9, 2016
@frvge
Copy link
Contributor

frvge commented Feb 12, 2016

See #271 for another point for the universal selector rule.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants