Side navigation
#1141 closed bug (worksforme)
Opened April 24, 2007 05:26AM UTC
Closed July 26, 2007 03:00AM UTC
$('#id').height() and $('#id').width() performance under IE7
Reported by: | Ihsahn | Owned by: | paul |
---|---|---|---|
Priority: | major | Milestone: | 1.1.3 |
Component: | dimensions | Version: | 1.1.2 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
There's a big problem with performance of $('#id').height() and $('#id').width() under IE. It's noticably slower than under FF or Opera. I had to switch to document.getElementById(id).offsetWidth and document.getElementById(id).offsetHeight to avoid freezing IE on resizing ;/
I will try to provide testcase for this, later.
Attachments (0)
Change History (5)
Changed April 24, 2007 05:45AM UTC by comment:1
Changed May 01, 2007 06:12PM UTC by comment:2
The slow performace is also visible in IE 6
Changed June 15, 2007 08:49PM UTC by comment:3
component: | dimensions → core |
---|---|
description: | There's a big problem with performance of $('#id').height() and $('#id').width() under IE. It's '''noticably''' slower than under FF or Opera. I had to switch to document.getElementById(id).offsetWidth and document.getElementById(id).offsetHeight to avoid freezing IE on resizing ;/\ \ I will try to provide testcase for this, later. → There's a big problem with performance of $('#id').height() and $('#id').width() under IE. It's '''noticably''' slower than under FF or Opera. I had to switch to document.getElementById(id).offsetWidth and document.getElementById(id).offsetHeight to avoid freezing IE on resizing ;/ \ \ I will try to provide testcase for this, later. |
resolution: | → worksforme |
status: | new → closed |
width and height methods in dimensions just fall back to the jQuery core when using a selector. If the element is hidden, then some extra steps are necessary to get the width and height. Please note that that width and offsetWidth are not the same thing. Getting the width and height of a hidden element is slow and should be cached and not called on window resize in IE since IE fires that event a lot!
Changed June 15, 2007 08:54PM UTC by comment:4
component: | core → dimensions |
---|---|
need: | Review → Test Case |
resolution: | worksforme |
status: | closed → reopened |
Hmmm ... I haven't been able to reproduce this. Could someone provide a test case? It seems this has been reported a few times now. I'm curious as to what is happening. Does the problem exist while still using dimensions?
Changed July 26, 2007 03:00AM UTC by comment:5
resolution: | → worksforme |
---|---|
status: | reopened → closed |
if !$('#id').is(:visible), jQuery tries to clone the node, append to DOM, calculate the dimension and remove the cloned node. These steps significantly slow down execution especially when the element is large.
The performance seems to be OK for me when the element is visible.