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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T19:03:50+00:00 2026-06-08T19:03:50+00:00

In modern browsers, jQuery makes use of document.querySelectorAll() to boost performance when valid CSS

  • 0

In modern browsers, jQuery makes use of document.querySelectorAll() to boost performance when valid CSS selectors are used. It falls back to Sizzle if a browser doesn’t support the selector or the document.querySelectorAll() method.

However, I’d like to always use Sizzle instead of the native implementation when debugging a custom selector. Namely, I’m trying to come up with an implementation of :nth-last-child(), one of the CSS3 selectors that are not supported by jQuery. Since this selector is natively supported by modern browsers, it works as described in the linked question. It is precisely this behavior that’s interfering with debugging my custom selector, though, so I’d like to avoid it.

A cheap hack I can use is to drop in a non-standard jQuery selector extension, thereby “invalidating” the selector so to speak. For example, assuming every li:nth-last-child(2) is visible, I can simply drop that in, turning this:

$('li:nth-last-child(2)').css('color', 'red');

Into this:

$('li:nth-last-child(2):visible').css('color', 'red');

This causes it to always be evaluated by Sizzle. Except, this requires that I make an assumption of my page elements which may or may not be true. And I really don’t like that. Not to mention, I dislike using non-standard selectors in general unless absolutely necessary.

Is there a way to skip the native document.querySelectorAll() method in browsers that support it and force jQuery to use Sizzle to evaluate a selector instead, that preferably doesn’t employ the use of non-standard selectors? Likely, this entails calling another method instead of $(), but it’s much better than a selector hack IMO.

  • 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-08T19:03:51+00:00Added an answer on June 8, 2026 at 7:03 pm

    You could just set it to null before jQuery loads so it thinks it’s not supported:

    document.querySelectorAll = null;
    //load jquery, will trigger not supported branch
    //Optionally restore QSA here (save a reference) if needed
    

    This is supposed to make this evaluate to false

    Demo: http://jsbin.com/asipil/2/edit

    Comment out the null line and rerun, and you will see it will turn red.

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

Sidebar

Related Questions

Modern browsers are supposed to support the CSS page-break properties to some degree. However
I am using simple CSS with modern browsers: IE 9 and Firefox 10. <link
I have created html/css for modern browsers (IE7 and above, firefox, etc) and am
For each of the modern browsers are there well known hooks I can tie
I know modern browsers remove most space chars and '&nbsp'; characters insider a paragraph
The following dropdown menu works fine in modern browsers (IE7/firefox) but not in IE6.
There is a common feature of modern browsers where a user can select some
I just came up with this, it seems to work in all modern browsers,
Generally speaking, when given a cookie that has no expiration period, modern browsers will
For desktop browser all modern browser uses Zoom functionality so we can use PX

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.