...

View Full Version : Setting cells' background-image: Too slow



supro
08-19-2005, 04:00 PM
I have a list of all the table cells that I want to change the style of in an array. Right now, I am going through the array in a for loop and changing the className of each cell. the new class sets a background-image on the corresponding cell which makes it really slow in IE. For some reason, that process is pretty fast in Mozilla.

Do you guys have any suggestions on how to make it faster?

I have tried using setTimeout to set background-image on each cell simultaneously but it's very buggy and still slow.
I have also tried only changing the background-image of cells that in the user's view but I can't afford to put a bunch of function calls to get the right position of each cell in that huge loop.

Thanks in advance.

medigerati
08-19-2005, 04:57 PM
maybe try setInterval...

supro
08-19-2005, 05:17 PM
Same thing...

supro
08-19-2005, 10:18 PM
Anyone? There must be some kind of solution...

martin_narg
08-19-2005, 10:21 PM
Can you post up your code please.

Then we can try and optimise from there.

Cheers

m_n

supro
08-22-2005, 03:39 PM
I goes something like this:



function updateAllCells(allcells)
{
for(var i=0; i<allcells.length; i++)
setTimeout("this.insideUpdate(" + i + ")", 1);

this.insideUpdate = function updateMyCell(i) {
allcells[i].className = "new_selection";
}
}

function updatefunc
{
var allSelectedCells = document.getElementByName(MYNAME);
updateAllCells(allSelectedCells)

}


I call updatefunc, but this process of selection is still slow.

supro
08-23-2005, 03:10 PM
PS: the above doesn't completely work either. If I select a group of cells and then some other group of cells, it won't deselect the first group. Some kind variable change issue going on...

glenngv
08-23-2005, 03:31 PM
IE has a background-image bug. It always requests the image from the server and does not get it from cache if the setting is set to "Every visit to page". There's even an article that discusses how to minimize the flickering background image.

http://www.fivesevensix.com/studies/ie6flicker/

supro
08-23-2005, 08:10 PM
Thanks, glenngv. Even if I cache my page (which most users will do anyway) the selection is still pretty slow. It's not as fast as when I change the background-color instead of background-image.
I've tried reducing the image size (transparent .gif) to 3x3 px but that doesn't really make a difference either.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum