views:

280

answers:

2

Hi,

In situations where a browser is under intense load I find that animated gifs, for example a throbber, will stop animating until the load subsides. This behaviour seem to be consistent across the browsers I've tried (Firefox, Safari, IE, Opera, ...).

Am wondering if there are any techniques I can use to ensure that animation continues during these periods.

Thanks! Matt

+1  A: 

You have no control on the page side except for reducing the load on the browser that the page actually contributes.

Maybe you could use the services of YSLOW to help you? It's a Firefox/Firebug plugin.

jldupont
Yes, I suspected as much :(
Matty
Look at my updated entry for an additional (maybe) helpful link.
jldupont
+2  A: 

You might be able to alleviate it by decreasing the length of time the browser spends on any particular task. Split out the JavaScript loading, or defer some of it. See if you really need to be doing all your JavaScript tasks right as the page loads. Defer some of the image loading, especially images below the fold.

Think of the browser as a single-threaded piece of code; you need to break up the tasks it has to do so that there's time in there to update the throbber animation.

Anthony Mills
I will give this approach a try. Just need to figure out the logical spots to break up the processing here. It's a period of "heavy lifting" that occurs in a web app subsequent to page load, where a significant amount of string manipulation if occurring. Will have to refactor to break that out into chunks.
Matty
Yeah, you can also look at techniques that would do a `window.setTimeout(f(), 0);` where `f()` continues the processing. (In other words, do some work, then `setTimeout` a function that will do more work.) That's one way of splitting up a big chunk of processing into lots of little chunks of processing, and the browser is better able to find time in there to update UI and keep things responsive.
Anthony Mills
Cool. Thanks for the advice. Thinking out loud - Might try a Flash throbber as a quick and dirty way to push the "animation" into a separate process, while working on the larger solution of refactoring what a big piece of legacy code.
Matty