#12269 closed bug (wontfix)
width() and height() significantly slower in 1.8 in WebKit browsers
Reported by: | twadzilla | Owned by: | mikesherov |
---|---|---|---|
Priority: | blocker | Milestone: | 1.8.1 |
Component: | css | Version: | 1.8.0 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
jQuery version: 1.8
Browsers affected: Chrome 21-23, Safari 5-6
Browsers not affected: IE, Firefox
Operating systems: Windows XP SP3, Windows 7 x64, Mac OS 10.7
Repro link: http://jsfiddle.net/jkvFN/
Expected result: when applying width() or height() over a large (500+) collection of elements, performance should be roughly equivalent to css().
Actual result: width() and height() perform several orders of magnitude slower than css() in 1.8.0 compared to 1.7.2. A trace in the timeline feature of Chrome seems to indicate a large number of layout/style recalculations happening in curCSS (line 6617).
Change History (8)
comment:1 Changed 10 years ago by
Component: | unfiled → css |
---|---|
Keywords: | needsdocs added |
Priority: | undecided → high |
Resolution: | → worksforme |
Status: | new → closed |
comment:2 Changed 10 years ago by
Resolution: | worksforme |
---|---|
Status: | closed → reopened |
Actually, maybe I got it backwards here. Sorry for that.
comment:3 Changed 10 years ago by
Yeah, this is interesting. I apologize for the hasty reply. I'm investigating now.
comment:4 Changed 10 years ago by
Right, so, this is slower in every browser, but more noticeable in webkit. This is due to what I had originally mentioned. It's still true that I've actually sped up some code paths when box-sizing:border-box is true, but also, we've become more precise with .width() vs. .css('width').
Again, .width() accounts for which box-sizing model is being used, and .css('width') does not. As a consequence, we query the box-sizing property when using .width(), which is the cause of the slowdown. Use .css('width') if you'd like to avoid this.
I'll continue to investigate this in the mean time.
comment:5 Changed 10 years ago by
Milestone: | None → 1.8.1 |
---|---|
Owner: | set to mikesherov |
Priority: | high → blocker |
Status: | reopened → assigned |
comment:6 Changed 10 years ago by
Resolution: | → wontfix |
---|---|
Status: | assigned → closed |
We discussed this at length at the team meeting. We are keeping this behavior, as although it may be slower. If you are not using border-box, use .css('width'). If you need it to be content-width regardless of box-sizing, use .width().
comment:7 Changed 10 years ago by
almost same problem on firefox 14.0.1 so linux ubuntu 12. JQuery 1.8.0 Advertencia: Propiedad desconocida 'box-sizing'. Declaración rechazada.
comment:8 Changed 10 years ago by
Keywords: | needsdocs removed |
---|
Actually, you should be happy. Change your tests to use jquery 1.7.2, and you'll see just how slow the old methods were. In jquery 1.8, I've significantly sped up certain code paths. As well, .width() as a setter and .css('width') as a setter do different things. .wdith() sets content width, where as .css('width') sets the "width" attribute, which can be content-width if box-sizing is content box, or content-width plus padding plus border if box-sizing is border-box.
Adding needsdocs because we haven't properly publicized this change.