I'm working with a consumer web app which uses GWT extensively and
also integrates several third-party services (ads, user tracking,
etc.) via script tags. (For context, we generate as much of our HTML
as possible, including those script tags, on the server side, and add
behavior with GWT. This keeps us search-engine friendly and reduces
the time to when the user begins to see interesting content.)
Unfortunately, all those third-party scripts run before GWT does,
since all of the scripts are in the page and run during page load,
while GWT runs on DOMContentLoaded. The result is that some prominent
page elements aren't drawn, and behavior isn't available, until all of
the third-party stuff is finished, which takes much too long (a couple
of seconds).

We'd rather have a happy user using the page right away and let the
ads and user tracking and such complete afterwards, so we'd like all
of the third-party stuff to run after GWT does. It seems as though the
right way would be to write the third-party script tags into the DOM
in our GWT code, after we've done all of the real application stuff
that we want to do first. My first crack at this was (warning, from
memory):

ScriptElement script = ScriptElement.as(DOM.createElement("script"));
script.setSrc("http:///third-party-service.com?...";);
script.setType("text/javascript");
Element container = DOM.getElementById("anId");
container.appendChild(script);

The above is at the end of my onModuleLoad. I also tried
DeferredCommand.add(new Command() {  // the same code }). Either way
the result is the same:

- in the hosted mode browser and IE 7, nothing happens (and there is
no error in the hosted mode browser)
- in Firefox 3,
  - the page loads until GWT gets around to running the above code
  - the script tag issues a request to the correct URL
  - the whole page is replaced by the content at that URL
  - Firebug reports an error in Google Maps code, which is running
from our app, not from the third-party tag
  - the browser hangs!

Can anyone either explain what's going on and suggest how to fix it,
or suggest another way to accomplish the goal?

Thanks!

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

Reply via email to