Given that I have a popup, with ID “popup” and in it two buttons, one on the left and one on the right side, with class “popupbutton”, which of these css rules is most efficient:
#popup a.popupbutton
#popup .popupbutton
a.popupbutton
.popupbutton
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The class will be quicker. But when you get down to it, you’re saving yourself something like 20-50ms (which may or may not matter).
There’s a pretty good test done you can read about here that looks at the difference in css selector speed across multiple browsers: http://www.stevesouders.com/blog/2009/03/10/performance-impact-of-css-selectors/
As you can see from the article, the difference of selector speed is pretty low and these tests were against pretty robust DOM examples.