Opened 12 years ago
Closed 12 years ago
#8262 closed bug (wontfix)
try/catch inside jQuery.style() has a negative impact on perf in Safari and Opera
Reported by: | lrbabe | Owned by: | |
---|---|---|---|
Priority: | low | Milestone: | 1.next |
Component: | css | Version: | 1.5 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
To prevent IE from throwing errors when 'invalid' values are provided, the line of code that sets a value to style property has been wrapped by a try/catch (see #5509)
This has a highly negative impact on performance both in Safari5 and Opera11, as shown by this test: http://jsperf.com/try-catch-impact-style#results
We could add a feature test to jQuery to detect when the browser throws an error for an invalid value and add it to jQuery.support.invalidStyle. We would then change the code in css.js to
jQuery.support.invalidStyle ? try { style[ name ] = value; } catch(e) {}: style[ name ] = value;
Change History (4)
comment:1 Changed 12 years ago by
comment:2 Changed 12 years ago by
Component: | unfiled → css |
---|---|
Priority: | undecided → low |
Status: | new → open |
Summary: | try/catch inside fn.style() has a negative impact on perf in Safari and Opera → try/catch inside jQuery.style() has a negative impact on perf in Safari and Opera |
comment:3 Changed 12 years ago by
On the other hand, a patched jQuery performs even worse in Firefox and Opera and only slightly better in Chrome and Safari. http://jsperf.com/jquery-style-try-catch-impact
It is probably better to leave it as is right now.
comment:4 Changed 12 years ago by
Resolution: | → wontfix |
---|---|
Status: | open → closed |
Closing as trying to avoid the try/catch makes situation even worse.
Oops, the try/catch is inside jQuery.style, not jQuery.fn.style