Bug Tracker

Ticket #14250 (closed bug: fixed)

Opened 2 years ago

Last modified 19 months ago

addClass and removeClass needlessly assign to className.

Reported by: jdunck Owned by:
Priority: low Milestone: 1.11/2.1
Component: attributes Version: 2.0.3
Keywords: Cc:
Blocking: Blocked by:


Assigning to className, even with the same value, triggers a re-render in some browsers. This can cause a noticeable render delay on mobile. On causes.com with a $(body).addClass applying an existing class, it took 200ms to render.

I'm not sure how to show this in jsfiddle.

Change History

comment:1 Changed 2 years ago by jdunck

comment:2 Changed 2 years ago by timmywil

  • Priority changed from undecided to low
  • Status changed from new to open
  • Component changed from unfiled to attributes
  • Milestone changed from None to 1.10.3/2.0.4

Seems like a good idea.

comment:3 Changed 2 years ago by dmethvin

  • Status changed from open to closed
  • Resolution set to fixed

Fix #14164: assign className in addClass/removeClass only if changed. Close gh-1331.

Changeset: c418b94eb48188cd9329519ae5e030a52dd81cc9

comment:4 Changed 2 years ago by dmethvin

  • Milestone changed from 1.10.3/2.0.4 to 1.11/2.1

Bulk update for new milestone

comment:5 Changed 20 months ago by martinsrosa@…

Thanks a lot. I have a really heavy website layout which I use lots of animations changing classes and I noticed a great improvement using jQuery 1.11 Beta 3 on it.  Before and  after the version.

comment:6 Changed 19 months ago by dmethvin

Note: See TracTickets for help on using tickets.