Loading please wait + Animated GIF

553 views
Skip to first unread message

Yogesh

unread,
Apr 13, 2010, 6:30:46 AM4/13/10
to Google Web Toolkit, yoges...@gmail.com
Hi,
I am showing a "Loading, please wait.." message along with an animated
gif.
For this I have added following in my host page.
<div id="loading"><img src="loading.gif"/> Loading Please wait..</div>
I have used http://www.ajaxload.info/ to generate a simple loading
GIF image.
And onModuleLoad() I am am removing this <div> before adding actual
components into Rool Panel. This is working fine.

The issue is that the animation of the GIF is not displayed. I found
out that when javascript code in mymodule.nocache.js starts running in
browser, the animation of GIF stops.

I even wrote following HTML page to test this. When I click on Click
me button, I just run some big for loop in javascript. When the
javascript is running, the animation of GIF is stopped.

<script>
function bigJS()
{
for (var i=1; i<=10000000; i++);
alert('done');
}
</script>
<BODY>
<div id="loading"><img src="loading.gif"/> Loading Please wait..</div>
<input id="btnClick" name="btnClick" type="button" value="Click me!"
onclick="bigJS()" />
</BODY>

Anyone know how to display the animated GIF properly?

Sripathi Krishnan

unread,
Apr 13, 2010, 7:43:34 AM4/13/10
to google-we...@googlegroups.com, yoges...@gmail.com
Javascript is single threaded, and I presume the entire page as well. If you are running a javascript loop, the animation will appear sluggish or will stop, there isn't much you can do about it.

If you want to run heavy javascript, use the IncrementalCommand or DeferredCommand patterns. This would allow the browser to do other activities, including animating the gif.

--Sri



--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-we...@googlegroups.com.
To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.


lineman78

unread,
Apr 14, 2010, 7:02:33 PM4/14/10
to Google Web Toolkit
I have noticed the same issue. I know that javascript runs single
threaded, but I believe that the gif animation should run on a
seperate thread. Have you run this experiment on browsers that use a
different threading model like the newer version of Chrome (soon
coming to FF). Just because javascript is single threaded doesn't
mean that the rendering engine needs to be on that same thread.

On Apr 13, 4:30 am, Yogesh <yogeshrn...@gmail.com> wrote:
> Hi,
> I am showing a "Loading, please wait.." message along with an animated
> gif.
> For this I have added following in my host page.
> <div id="loading"><img src="loading.gif"/> Loading Please wait..</div>

> I have usedhttp://www.ajaxload.info/ to generate a simple loading

Reply all
Reply to author
Forward
0 new messages