Start gwt as soon as it is loaded, do not wait for page load?

635 views
Skip to first unread message

Ali

unread,
May 14, 2012, 10:29:05 PM5/14/12
to google-we...@googlegroups.com
Hi,

Is there any way to start running gwt as soon as it's loaded and do not wait for page to load?

I think this is a related submitted issue: http://code.google.com/p/google-web-toolkit/issues/detail?id=4513

A work around is mentioned there but I don't know how to create custom linker (and prefer an easier workaround). I'm using xsiframe.

Any idea is appreciated.

-ali

Joseph Lust

unread,
May 15, 2012, 5:40:43 PM5/15/12
to google-we...@googlegroups.com
If you must you could add any desired JS to the launch HTML page so that this simple JS could run before GWT is ready. However, I don't see the GWT team making an "onEarlyModuleLoad" handler since you'd then have to assure that nothing using the DOM or UiBinder was called from those methods. That would create nearly 2 applications and you'd delay the main module load with the pre module load (which would need its own boot strapper).

For most applications, the more important aspect is the appearance of loading quickly. To that end the default HTML/CSS of the page could be setup to show some graphics/animations before any GWT resources are loaded to give the user the impression of a faster loading app.

Sincerely,
Joseph

Ali

unread,
May 16, 2012, 9:05:25 AM5/16/12
to google-we...@googlegroups.com
Thank you. As you have advised the page is basically a html/css page and gwt is mainly used to interact with server, for example when user clicks on a like button.

Just an additional question, is it the expected behavior that gwt does not starts until all images in a page are loaded?

best,
ali

Joseph Lust

unread,
May 16, 2012, 2:26:45 PM5/16/12
to google-we...@googlegroups.com
The loading order and which elements are blocking to GWT's execution is explained well here. By changing the order of said items you can speed up the apparent loading of the page.

You can also see other examples of how to make a splash screen with GWT such as this.


Sincerely,
Joseph

Ali

unread,
May 17, 2012, 5:13:47 AM5/17/12
to google-we...@googlegroups.com
Thanks, I read it carefully:
  • <img> tags do not block page evaluation.
  • The body.onload() event will only fire once all external resources are fetched, including images and frames.
  • The GWT selection script will be fetched and evaluated like a normal script tag, but the compiled script will be fetched asynchronously.
  • Once the GWT selection script has started, its onModuleLoad() can be called at any point after the outer document has been parsed.
  • <img> tags are not guaranteed to be done loading when onModuleLoad() is called.
It seems that it is not unexpected that image loading block gwt execution? It would be great if there is anyway to avoid it (execute gwt as soon as document has been parsed).

Thanks,

-ali

Ali

unread,
May 18, 2012, 12:51:49 PM5/18/12
to google-we...@googlegroups.com
This minimal code can reproduce my problem using xsiframe linker:

public class MyEntryPoint implements EntryPoint {
    public void onModuleLoad() {
        Window.confirm("onModuleLoad");
    }
}

<html><head>
    <script type="text/javascript"src="app.nocache.js"></script>
</head><body>
    <!-- http://stackoverflow.com/questions/100841/artificially-create-a-connection-timeout-error -->
    <img src="http://10.255.255.1/" alt="timeout image" />
</body></html>

Joseph Lust

unread,
May 18, 2012, 1:50:15 PM5/18/12
to google-we...@googlegroups.com
Help me understand here. You're saying that this image load failure prevents the rest of the application from loading?

Perhaps you can:
  • Not load the image and base64 encode it into a dataURL (nice tool) in your page.
  • Let ImageResource ClientBundle do the above for you in GWT (assuming image is not too large)
  • Dynamically load the image after page load (after GWT script is loaded) either from onLoad() or from GWT client code
But, from what you copied in from the GWT docs, it would appear that the img would not block GWT from running (it's not using onLoad()) , but would block anything else using onLoad().


Sincerely,
Joseph

Ali Sakebi

unread,
May 18, 2012, 4:04:20 PM5/18/12
to google-we...@googlegroups.com
In my app static pages are server to users, they are viewable without
any gwt (ajax) but to dynamically interact with server gwt is used.

There are pages which contain user generated content (like a blog
post), they can include images with external href. Some time it takes
too long for an image to be loaded or fail, like in the sample code.
This blocks gwt from being started. In firebug and chrome I can see
that gwt scripts are loaded but they are not started until image
loading is done or failed.

Any way thanks for you help, I guess this is a xsiframe linker bug and
I need to submit an issue.

On 5/18/12, Joseph Lust <lifeo...@gmail.com> wrote:
> Help me understand here. You're saying that this image load failure
> prevents the rest of the application from loading?
>
> Perhaps you can:
>
> - Not load the image and base64 encode it into a dataURL (nice
> tool<http://dataurl.net/#about>)
> in your page.
> - Let ImageResource ClientBundle do the above for you in GWT (assuming
> image is not too large)
> - Dynamically load the image after page load (after GWT script is
> loaded) either from onLoad() or from GWT client code
>
> But, from what you copied in from the GWT docs, it would appear that the
> img would not block GWT from running (it's not using onLoad()) , but would
> block anything else using onLoad().
>
>
> Sincerely,
> Joseph
>
> --
> You received this message because you are subscribed to the Google Groups
> "Google Web Toolkit" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/google-web-toolkit/-/ndhZo3Rr2osJ.
> 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.
>
>
Reply all
Reply to author
Forward
0 new messages