Load the GWT component after the page renders

159 views
Skip to first unread message

esteban

unread,
Jun 16, 2011, 3:16:00 AM6/16/11
to Google Web Toolkit
Hi everyone,
I have a question: is there any way that i can load GWT after the page
is rendered?
Thanks

Juan Pablo Gardella

unread,
Jun 16, 2011, 12:07:18 PM6/16/11
to google-we...@googlegroups.com
GWT compile to javascript. So the question "is there any way that i can load javascript after the page
is rendered?" I google this



2011/6/16 esteban <esteban...@gmail.com>

--
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.


Thomas Broyer

unread,
Jun 16, 2011, 12:20:15 PM6/16/11
to google-we...@googlegroups.com
Putting the <script> at the end of your page (just before the </body>) should be enough in most cases.

You cannot use <script defer> or <script async> because nocache.js files make use of document.write() which would blow your page if it's already loaded. At least with the provided linkers, but you could make your own linker…
(FYI, the document.write() are used to inject the <script src=""/> you might have in your *.gwt.xml, and make sure they're all loaded before your onModuleLoad is called)

Esteban García

unread,
Jun 16, 2011, 3:16:07 PM6/16/11
to google-we...@googlegroups.com
Thanks for the response. Actually, putting the <script> at the end of your page, is not enough in my case.
The idea of making my own linker doesn't like me a lot either.
The document.write() problem was the reason why I wrote the email  in the first place.

2011/6/16 Thomas Broyer <t.br...@gmail.com>
Putting the <script> at the end of your page (just before the </body>) should be enough in most cases.

You cannot use <script defer> or <script async> because nocache.js files make use of document.write() which would blow your page if it's already loaded. At least with the provided linkers, but you could make your own linker…
(FYI, the document.write() are used to inject the <script src=""/> you might have in your *.gwt.xml, and make sure they're all loaded before your onModuleLoad is called)

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.

lemaiol

unread,
Jun 17, 2011, 6:26:57 AM6/17/11
to Google Web Toolkit
Hi Esteban,

You have already two linkers that you can use: xs and xsiframe. The
first is not supported in dev mode and is a little old. I would
recommend to use the xsiframe linker. The problem is the scarce
documentation about linkers and some side effects that they could have
on your application :(

You can also "hack" the write problem by overriding the write method
in JS ("window.write = function() {...}"). More or less, the thing to
do there is adding a new "script" node in the header with the URL sent
in the parameter of the write call. Should be almost the same node
content but instead of write you should manipulate the DOM with JS.
Start with "var oldWrite = window.write; window.write =
function(param) {alert(param); window.write = oldWrite;};". From the
on, figure out and have fun! :)

cheers,
Berto

Thomas Broyer

unread,
Jun 17, 2011, 9:02:34 AM6/17/11
to google-we...@googlegroups.com


On Thursday, June 16, 2011 9:16:07 PM UTC+2, esteban wrote:
Thanks for the response. Actually, putting the <script> at the end of your page, is not enough in my case.
The idea of making my own linker doesn't like me a lot either.
The document.write() problem was the reason why I wrote the email  in the first place.

Good news, according to this message https://groups.google.com/d/msg/google-web-toolkit/C_gbOJL3wmE/7cRqNmgWEjwJ the xsiframe linker supports "late loading" (and Berto / lemaiol says the "xs" linker does too?) 
Reply all
Reply to author
Forward
0 new messages