Bug Tracker

Modify

Ticket #3471 (closed enhancement: wontfix)

Opened 5 years ago

Last modified 5 years ago

Performance suggestion on selector

Reported by: sandstrom Owned by:
Priority: trivial Milestone: 1.3
Component: selector Version: 1.2.6
Keywords: performance, selector, Cc:
Blocking: Blocked by:

Description

It's common to set the id of body to something page-specific (eg. body id="unique" or id="controller-action" in an MVC setup). Thus one can easily target code to specific pages.

Example: $('body#login-email input#specific').focus();

I don't know if it would be a performance benefit, perhaps it would be an idea to have jquery return (cancel) queries through the dom when the id is set for a body element, and there is nothing on the body element. So instead or parsing several hundred dom nodes one would go straight for the body, and if it's not there one can abort.

Change History

comment:1 Changed 5 years ago by scott.gonzal

  • Status changed from new to closed
  • Resolution set to wontfix

This doesn't scale to other elements besides the body and it doesn't make sense to add in extra checks just for this special case. Why not just wrap all your code in a check?

if ($('body').is('#something')) {
    // page-specific code
}

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.