Respond
Respond copied to clipboard
IE8 Triggers resize events on DOM changes
As the title suggests, IE8 triggers resize events ( http://stackoverflow.com/questions/1852751/window-resize-event-firing-in-internet-explorer ) whenever the DOM changes. Since the applyMedia function alters the DOM, it is also triggering a resize event. This is somewhat alleviate by the function throttling but on slower computers it keeps the cpu usage quite high and sometimes causes crashes.
One work around would be to only call the applyMedia function when ever the the window height/width. See below.
respond.currentHeight = 0;
respond.currentWidth = 0;
function callMedia(){
var currentHeight = 0;
var currentWidth = 0;
currentHeight = window.innerHeight || document.documentElement.clientHeight;
currentWidth = window.innerWidth || document.documentElement.clientWidth;
if (respond.currentHeight != currentHeight || respond.currentWidth != currentWidth) {
respond.currentWidth = currentWidth;
respond.currentHeight = currentHeight;
applyMedia( true );
}
}
Also experiencing high CPU usage (IE8, WinXP)