Move offset check to the back in JQUERY.EXPR.FILTERS.HIDDEN to optimize ... #1027

wants to merge 1 commit into


None yet
5 participants

...performance. Fixes #12885.

I did not test it because the instructions on how to run grunt are incomplete/broken. The 'grunt && grunt watch' command does build jQuery.js but no tests are run and no (web)server is started. AFAIK, grunt watch is not meant for this task. Shouldn't it be grunt test?


staabm commented Nov 12, 2012

Great find! Did you test it on Jsperf ?


timmywil commented Nov 12, 2012

@rspilker: Sorry for the confusion. grunt watch is there to help you build jQuery as you make changes. To actually test, follow the instructions right after that on setting up a local server with PHP (and opening test/index.html from localhost).

Also, it would be great to see perf tests so we can be sure this is actually faster. Even if the codepath for curCSS is not hit very often, that could potentially slow it down if there are multiple elements on the page that require it. I suggest making two tests: one with lots of different kinds of elements(i.e. elements with different tag names) that are hidden and one with only one hidden element on the page.


gnarf commented Nov 25, 2012

The ajax failure in the build went away after a retest.


dmethvin commented Dec 5, 2012

@rspilker can you sign the CLA at ?

rspilker commented Dec 6, 2012



dmethvin commented Dec 7, 2012

I am not sure about the perf. I was trying to test was whether gCS caused a reflow when asked for the display property, because we know that offsetHeight will do so if any dimensions have changed. Seems like it may vary widely by browser, or perhaps my perf is too crummy.


dmethvin commented Dec 11, 2012

The bench from @timmywil wasn't very definitive either, although I had some problems running it on Chrome. I'd say we should leave the code as-is without proof that it improves, since the risk of regression is high.

@rspilker don't be discouraged by this, please do let us know if you're interested in taking on any of the tickets in the tracker. If is the possibility of a perf regression it's always a good idea to do a jsperf.

dmethvin closed this Dec 11, 2012

I'm not discouraged. I understand your reasoning and agree.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment