PDA

View Full Version : YAHOO.util.Element.get('some_id') vs getEl('some_id')



christocracy
23 Oct 2006, 8:01 PM
YAHOO.util.Element.get('some_id') vs getEl('some_id')

is the performance difference negligible?

jack.slocum
24 Oct 2006, 9:29 AM
They both point to the same function. getEl is just a shorthand function.

var getEl = YAHOO.ext.Element.get;

christocracy
24 Oct 2006, 9:32 AM
I'm aware that

var getEl = YAHOO.ext.Element.get;

but,

YAHOO.util.Element.get('some_id') != YAHOO.ext.Element.get('some_id');

right?

jack.slocum
24 Oct 2006, 10:11 AM
what is YAHOO.util.Element.get?

christocracy
24 Oct 2006, 10:15 AM
>what is YAHOO.util.Element.get?

urmmm...how 'bout YAHOO.util.Dom.get

damn i hate looking dumb :)

jack.slocum
24 Oct 2006, 10:21 AM
Dom.get() returns a normal DOM node. YAHOO.ext.Element.get returns a YAHOO.ext.Element object which is loaded with additional functionality and animations and auto box adjustments etc.

http://www.jackslocum.com/docs/YAHOO.ext.Element.html

christocracy
24 Oct 2006, 10:32 AM
>returns a YAHOO.ext.Element object which is loaded with additional functionality
>and animations and auto box adjustments etc.

exactly, so back to my first question:

should a guy use Dom.get where he's not going to use all that functionality or is the performance difference negligible?

my brain is melting.
too much noo too quickly.

jack.slocum
24 Oct 2006, 5:05 PM
Yes, I use Dom.get or document.getElementById where I am working with a lot of elements for performance reasons. The difference is not as drastic as you might think though. getEl() is faster on subsequent lookups though because it caches the dom node (avoiding the dom lookup).