Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9134443
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T08:39:36+00:00 2026-06-17T08:39:36+00:00

According to mdn : The descendant selector is the most expensive selector in CSS.

  • 0

According to mdn :

The descendant selector is the most expensive selector in CSS. It is
dreadfully expensive—especially if the selector is in the Tag or
Universal Category.

When Modernizr is up , it adds all the non supported classes to the html tag.

Meaning he can later do :

.myNotSupportedClass .myLastDiv   <-- notice descendants selecotr[ ]
{
  color:red;
}

But this is absolutely slow operation an operation which can be optimized…. which has to go through all the DOM tree in order to find the div.
I know there isn’t another way of doing it , but still :

1) they could have added those classes to the body/form which is closer to the elements. soo there will be less of searching.

Or am I wrong …,?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T08:39:37+00:00Added an answer on June 17, 2026 at 8:39 am

    But this is absolutely slow operation

    Eh.

    they could have added those classes to the body/form which is closer to the elements. soo there will be less of searching.

    body: how much less searching? 1 level less? How much of a difference does that make?

    form: not every page has a form, and pages can have more than one form. The form element itself can be placed anywhere in the page body too, so the elements that should be affected by selectors in Modernizr class context may very well be unrelated to it, making searching completely impossible.

    Do whatever you like, but since Modernizr chooses to place classes on the html element, write contextual selectors that make use of those classes and the descendant selector. If you’re that obsessive about descendant selector performance, you have the choice not to use Modernizr and lose all the feature detection goodness it brings.

    Why it chooses to place classes on the html element is anybody’s guess. It could have been the most convenient element to place them on.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

According to the MDN JS Doc , the charAt method takes in an integer
According to this MDN page , the delete keyword Returns false only if the
According to the String.prototype.replace() page on MDN , I should be able to easily
According to the mustache RFC A {{name}} tag in a basic template will try
according to mdn documentation the method removeChild removes a node from the DOM but
According to the MDN page at for each...in loop , this construct is deprecated.
According to the MDN wiki, DOMContentLoaded will fire when page's DOM is ready, [although]
According to WHATWG and MDN , window.setTimeout and window.setInterval have the form var handle
So according to MDN (it makes sense) the AnimationEvent has the bubble argument but
According to the CSS 2.1 standard, the vertical margins of floating elements should not

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.