Currently Javascript resources can be (1) put directly in the HTML
page 'manually', (2) put in a script tag in the GWT manifest or (3)
put in a ClientBundle as a TextResource and then injected into the
DOM.  I believe the last is a good option for many scenarios,
particularly dynamic includes; it also avoids a network round-trip.

I wrote a simple wrapper for this third option; it adds a method
ensureInjected() just like CssResource.  This also allows for
additional Javascript-specific features: e.g. it calls the Closure
minifier (in 'simple' mode) to automatically minify the Javascript.
The code is on github here:
https://github.com/fathomdb/gwt-utils/commit/5b504b98b29ba27e0826f61cc128ae66e61458fb

I have a few TODOs in there: not always calling the minifier, support
for external resources, and combination of multiple external scripts
(c.f. images bundled into a sprite).

I already find this useful as-is; would others?  Should I try to
contribute this to GWT?

Justin

-- 
http://groups.google.com/group/Google-Web-Toolkit-Contributors

Reply via email to