Opened 11 years ago
Closed 10 years ago
#12885 closed feature (notabug)
Optimize jQuery.expr.filters.hidden
Reported by: | dmethvin | Owned by: | Timmy Willison |
---|---|---|---|
Priority: | low | Milestone: | 1.9 |
Component: | css | Version: | 1.8.3 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description (last modified by )
http://forum.jquery.com/topic/optimize-jquery-expr-filters-hidden
Wouldn't it make sense to alter the order of the expressions in jQuery.expr.filters.hidden to only do the expensive work (elem.offsetWidth) after evaluating the parts that don't trigger a reflow? In the case the element is determined to be hidden by the style, it does not trigger a reflow anymore, what would be a nice behavior for a hidden element.
So instead of
return ( elem.offsetWidth === 0 && elem.offsetHeight === 0 ) || (!jQuery.support.reliableHiddenOffsets && ((elem.style && elem.style.display) || curCSS( elem, "display" )) === "none");
do
return (!jQuery.support.reliableHiddenOffsets && ((elem.style && elem.style.display) || curCSS( elem, "display" )) === "none") || ( elem.offsetWidth === 0 && elem.offsetHeight === 0 );
Roel
Change History (7)
comment:1 Changed 11 years ago by
Component: | unfiled → css |
---|---|
Description: | modified (diff) |
Milestone: | None → 1.9 |
Priority: | undecided → low |
Status: | new → open |
comment:2 Changed 11 years ago by
comment:3 Changed 11 years ago by
I think display just looks at the property for that element so no recalc should be required. The offset properties definitely require a recalc if one hasn't already been done, I'm always seeing big delays on offsetWidth/Height in profile runs for IE.
comment:5 Changed 11 years ago by
@dmethvin: I'm wondering, is offsetWidth/Height faster even when the codepath hits defaultDisplay? But even if it is, this is probably a better way to go.
comment:6 Changed 11 years ago by
Owner: | set to Timmy Willison |
---|---|
Status: | open → assigned |
Version: | git → 1.8.3 |
Will create a perf
comment:7 Changed 10 years ago by
Resolution: | → notabug |
---|---|
Status: | assigned → closed |
Based on the perf we decided not to land this.
I'm fine with it, but isn't display calculation a lot more expensive in IE than
.offsetWidth/.offsetHeight
?