Loading ...
Sorry, an error occurred while loading the content.

Which is Quicker...?

Expand Messages
  • wwempire
    YAHOO.util.Dom.getElementsByClassName( someclass , DIV ,YAHOO.util.Dom.get( someId )) or YAHOO.util.Dom.getElementsByClassName( someclass ); I ask because the
    Message 1 of 2 , Jul 4, 2006
    View Source
    • 0 Attachment
      YAHOO.util.Dom.getElementsByClassName('someclass','DIV',YAHOO.util.Dom.get('someId'))

      or

      YAHOO.util.Dom.getElementsByClassName('someclass');

      I ask because the docs say you get a perf boost if you provide an root
      node -- but is that perf increase cancelled out (if you will) when you
      make the .get() call?
    • Matt Warden
      ... It will depend on your particular DOM tree. I suspect that in most cases the first will be faster, partially because of the root but also because of the
      Message 2 of 2 , Jul 4, 2006
      View Source
      • 0 Attachment
        On 7/4/06, wwempire <carson@...> wrote:
        > YAHOO.util.Dom.getElementsByClassName('someclass','DIV',YAHOO.util.Dom.get('someId'))
        >
        > or
        >
        > YAHOO.util.Dom.getElementsByClassName('someclass');
        >
        > I ask because the docs say you get a perf boost if you provide an root
        > node -- but is that perf increase cancelled out (if you will) when you
        > make the .get() call?

        It will depend on your particular DOM tree. I suspect that in most
        cases the first will be faster, partially because of the root but also
        because of the tag name parameter. But, let's say your element with id
        someId is the body element. In this case, the first will probably be
        slower (but, again, that will depend on the % of div elements in the
        subtree).

        Note also that you can simply provide the root's id. The method calls
        get() internally anyway.

        --
        Matt Warden
        Oxford, OH, USA
        http://mattwarden.com


        This email proudly and graciously contributes to entropy.
      Your message has been successfully submitted and would be delivered to recipients shortly.