Bug Tracker

Opened 11 years ago

Closed 11 years ago

#3471 closed enhancement (wontfix)

Performance suggestion on selector

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

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 (1)

comment:1 Changed 11 years ago by scott.gonzal

Resolution: wontfix
Status: newclosed

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
}
Note: See TracTickets for help on using tickets.