the only real cost differential here is that addClass must transform a
string, where set(name, value) assigns a value. addClass basically calls
set('class', result) for you, computing the result. String transformations
are very fast though, so I doubt you would notice the difference.On Wed, Nov 25, 2009 at 8:21 AM, Roman Land <[email protected]> wrote: > Your welcome! > > Just wanted to add that this is all from my experience and research I have > previously done on similar questions, and if anyone knows differently please > let me know! > > Cheers > -- Roman > > > On Wed, Nov 25, 2009 at 5:59 PM, stratboy <[email protected]> wrote: > >> Thank you Roman :) >> >> On 25 Nov, 14:23, Roman Land <[email protected]> wrote: >> > As always the answer comes down to how many elements are affected, >> usually >> > with "addClass" and alike actions it will take you usually longer to run >> the >> > selector that finds your element, than actually setting the element's >> > "class" attribute. >> > The clear winner in performance is obviously the one that doesnt do any >> > concatenations (setClass), but this is really minimal, the general rule >> is, >> > if you think you will need the extra functionality dont worry about the >> > performance, do optimizations later if needed! >> > >> > >> > >> > On Wed, Nov 25, 2009 at 3:07 PM, stratboy <[email protected]> wrote: >> > > I already said that. Anyone can answer the real question? >> > >> > > On 25 Nov, 11:59, אריה גלזר <[email protected]> wrote: >> > > > aside from the faster question, i would think that addClass is >> better for >> > > it >> > > > allows extra behavioral functionality (for example adding instead of >> > > setting >> > > > etc.) >> > > > ----------- >> > > > אריה גלזר >> > > > 052-5348-561 >> > > > 5561 >> > >> > > > On Wed, Nov 25, 2009 at 12:27, stratboy <[email protected]> >> wrote: >> > > > > elem.set('class','rco-topleft') >> > >> > > > > elem.addClass('class','rco-topleft') >> > >> > > > > what's the faster/better? >> > >> > > > > Yes, i know, addClass can add a class, class='class1 class2 rco- >> > > > > topleft', so it's different. But still the questions, in that >> case. >> > >> > -- >> > --- >> > "Make everything as simple as possible, but not simpler." >> > >> > - Albert Einstein >> > > > > -- > --- > "Make everything as simple as possible, but not simpler." > > - Albert Einstein > >
