[jQuery] Re: PERFORMANCE TIP: removeClass()

2007-09-19 Thread Jonathan Sharp
Here's a rough outline of the code/style in question. My plugin will position an element in one of 16 predefined locations and add a css class pertaining to that location (eg. location1). It knows nothing about the element it's positioning. When it adds the location css class it first has to remov

[jQuery] Re: PERFORMANCE TIP: removeClass()

2007-09-19 Thread Karl Swedberg
On Sep 19, 2007, at 1:31 PM, Stephan Beal wrote: On Sep 19, 6:55 pm, "Jonathan Sharp" <[EMAIL PROTECTED]> wrote: I had 15 classes I had to remove and Firefox was a champ at chained removeClass calls, IE was taking 760ms! If i'm not mistaken, IE takes so long in that case because it has to ema

[jQuery] Re: PERFORMANCE TIP: removeClass()

2007-09-19 Thread Andy Matthews
On Vista at least. -Original Message- From: jquery-en@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Stephan Beal Sent: Wednesday, September 19, 2007 12:31 PM To: jQuery (English) Subject: [jQuery] Re: PERFORMANCE TIP: removeClass() On Sep 19, 6:55 pm, "Jonathan

[jQuery] Re: PERFORMANCE TIP: removeClass()

2007-09-19 Thread Andy Matthews
I might argue that if you're having to add/remove 15 classes, that your time could be better spent optimizing your display code. andy _ From: jquery-en@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Jonathan Sharp Sent: Wednesday, September 19, 2007 11:55 AM To: jquery-en@goo

[jQuery] Re: PERFORMANCE TIP: removeClass()

2007-09-19 Thread Gordon
Good rule of thumb in all programming is to keep function calls to a minimum. Chaining is a powerful jQuery feature but it's also expensive even in script engines that aren't as utterly awful as IE's. This is a prime example. Another tip that's pertinent to Javascript and jQuery is DOM access i

[jQuery] Re: PERFORMANCE TIP: removeClass()

2007-09-19 Thread Stephan Beal
On Sep 19, 6:55 pm, "Jonathan Sharp" <[EMAIL PROTECTED]> wrote: > I had 15 classes I had to remove and Firefox was a champ at chained > removeClass calls, IE was taking 760ms! If i'm not mistaken, IE takes so long in that case because it has to email the results of each function call to Microsoft

[jQuery] Re: PERFORMANCE TIP: removeClass()

2007-09-19 Thread Jonathan Sharp
I'm not sure how it compares but the case I'm talking about isn't simply removing all classes. I'm removing a subset of the classes and I don't arbitrarily know what other classes may be on the element. -js On 9/19/07, seedy <[EMAIL PROTECTED]> wrote: > > > > just curious how would that compare

[jQuery] Re: PERFORMANCE TIP: removeClass()

2007-09-19 Thread seedy
just curious how would that compare to $(...).attr('class',''); Jonathan Sharp-2 wrote: > > *Do not do:* > $(...).removeClass('a').removeClass('b').removeClass('c'); > > *Instead do:* > $(...).removeClass('a b c'); > > Same applys to addClass() > > I had 15 classes I had to remove and Firef