Bug Tracker

Ticket #14979 (closed bug: fixed)

Opened 17 months ago

Last modified 17 months ago

Order of conditions causes unnecessary Reflow

Reported by: ksmwsk@… Owned by:
Priority: high Milestone: 1.11.1/2.1.1
Component: dimensions Version: 2.1.0
Keywords: Cc:
Blocking: Blocked by:


When profiling a web application which features live resizing with its components i found a spot in the jQuery code causing unnecessary reflow.

return elem.offsetWidth === 0 && rdisplayswap.test( jQuery.css( [...]

if i change this so that the test for the display value will be the first one:

return rdisplayswap.test( jQuery.css( [...])) && elem.offsetWidth === 0

Now offsetWidth seems to take much more performance than retrieving the display property and testing it with the regexp.

If this will be confirmed as a valid issue, i would love to contribute this change via github.

Change History

comment:1 Changed 17 months ago by dmethvin

  • Priority changed from undecided to high
  • Status changed from new to open
  • Component changed from unfiled to dimensions
  • Milestone changed from None to 1.11.1/2.1.1

Awesome, great catch! We'd love a pull request on this.

comment:2 Changed 17 months ago by anonymous

Okay i will add a pull request today.

comment:3 Changed 17 months ago by ksmwsk@…

I added a pull request here:


comment:4 Changed 17 months ago by Christian Kosmowski

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

Dimensions: Reverse a check to avoid potential reflows

Fixes #14979 Closes gh-1560

Changeset: 1ca84214cc89d9e5f8af12b18b34426fc91b1b08

Note: See TracTickets for help on using tickets.