Dev Tip: Faster Selects w/Tag Name

Posted on by



is faster than:





10 thoughts on “Dev Tip: Faster Selects w/Tag Name

  1. Pingback: » Velocidad en la selecciÃ³n de elementos en jQuery - Scriptia

  2. Joe Kohlmann on said:

    Would JQuery also perform faster if the element selector hierarchy were more directly specified in the $() function query?
    $(‘#content dl dt a’) versus $(‘#content dt a’)
    Thanks for the tip, by the way.

  3. Chris Domigan on said:

    On a related note, does anyone know if browsers implement CSS faster if your style sheets are similarly structured? i.e. with element.class instead of just .class.

    Obviously when it comes to structuring your style sheet/s it’s a lot easier having just the class name so you can tell at a glance what the style is for!


  4. I haven’t dug through the code for this, certainly, but when I read the notation that when using an ID you shouldn’t use any other selector for optimum performance, my first thought was, “could you just ignore the rest of the selector if an ID is used?” (Although I suppose that would break in the case where there was, say, a TD element with a specified ID in the doc, but the jQuery call used a selector “TH #id”…

    jQuery looks pretty amazing, though. I’ve been looking at using Prototype for some upcoming development work but I think now that I may go with jQuery instead.