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 9040585
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T10:01:28+00:00 2026-06-16T10:01:28+00:00

I have the following HTML: <div class=foo> <div class=bar> <div class=target> </div> </div> </div>

  • 0

I have the following HTML:

<div class="foo">
    <div class="bar">
        <div class="target">
        </div>
    </div>
</div>

Which selector is more efficient?

  • $('.foo > .bar > .target')
  • $('.foo .bar .target')
  • $('.target')

Did I order them correctly? 🙂

  • 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-16T10:01:31+00:00Added an answer on June 16, 2026 at 10:01 am

    Be careful not to get too caught up in these types of issues – micro-optimization can really ruin a project. Not that it isn’t good to ponder from time to time, but sincerely, be cautious.

    If you still would like to know which of those three are faster, you can setup a quick performance test via http://jsperf.com and give them all three a run against that markup. Fortunately for you, I’ve saved you the hassle and setup the test myself 😉 http://jsperf.com/css-selector-specificity

    Results:

                                  Ops/Sec
    ----------------------------+---------+--------+------------
    $('.foo > .bar > .target'); |  78,379 | ±6.54% | 65% slower
    $('.foo .bar .target');     |  78,499 | ±7.72% | 66% slower
    $('.target');               | 213,488 | ±0.39% | fastest
    

    As you can see, the simplest of the three was much faster. Your results will vary from browser to browser. For instance, the above is from Chrome version 23. When I ran this test in Internet Explorer 10, it was even faster, with over 216,000 operations a second.

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

Sidebar

Related Questions

If I have the following HTML markup: <div class="foo">bar</div> How can I find which
I have the following html code: <div class=outer ui-draggable style=position: relative;> <div class=inner>Foo bar</div>
I have the following HTML: <div> <p>foo</p> <p class='foo'>foo</p> <p class='foo'>foo</p> <p>bar</p> </div> How
I have the following HTML: <DIV class=foo bar></DIV> I'm trying to create a CSS
I have the following code: HTML : <div id='example'> <a href='#' data-name='foo' class='example-link'>Click Me</a>
Suppose I have the following HTML: <div class=foo> <ul> <li>One</li> <li>Two</li> </ul> </div> <!--
I have the following html. <div> <img class=foo> <a href=# onClick=changeImage(this, param1, param2)>sth</a> </div>
I have the following HTML code: <div id=scroll> <div class=foo>foo1</div> <div class=foo>foo2</div> .... <div
I have following html structure: <div id=123 class=test> <div class=testMessage>Foo</div> <div><div class=testDate>2010</div></div> <div id=127
Just a small question. Say I have the following HTML: <div class=foo> {text} </div>

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.