views:

1063

answers:

2

When I have a modal JQuery dialog open in IE8, my CPU usage goes to 100% (no, actually 50, but that's 100% of one core). If I break developer tools, it seems that it's a lot of resize events firing (I don't do any volontary resizing). Has someone else encountered this issue and knows how to fix it?

+3  A: 

I've seen things like this happen when something is filling a container at 100% width and height, and that container has overflow:auto. Which makes it bounce back and forth endlessly trying to fit in the container, but then the container adds or removes scrollbars. Don't know if this is applicable to your situation, but maybe something similar.

lod3n
What do you mean with filling a container? There does appear scrollbars on the document for me when I popup the dialog, so you're probably at least partly right. However, the body is not even close to filled with things.
erikkallen
I mean when an inner element is the same size as (or slightly bigger than) a parent element. If you're seeing scrollbars, then it looks like this is happening to you. You need to find out what which element is doing this, and style it so it remains smaller than the parent element. The CPU usage is due to the repeated reflow that occurs when scrollbars are added and removed repeatedly. You might consider simply setting the body to overflow:hidden while the dialog appears, then back to whatever it was after it's closed.
lod3n
Thanks. This solution works, but is a little too cumbersome (think nested dialogs). I will accept it if nobody comes up with a better idea.
erikkallen
Again, the only thing which takes up 100% (or even close to that) of the body is the dialog overlay.
erikkallen
+1  A: 

The solution is to add this to your CSS file:

.ui-widget-overlay {
   position: fixed;
}

reference

erikkallen
Sorry for accepting my own answer, but I do think it is the best solution. Not supported by IE6, but IE6 has a different code path in the relevant jQuery code anyway (and I don't know if there is a problem).
erikkallen