I have a simple GWT program:
https://gist.github.com/kirillp/c443966b28ca68cd21e51ff802fde97d
And it compiles and run.
However, in single permutation "safari" and SSO linker it produce about 1100 lines of (auto-formatted) code including
user agent parser, adds a window listener, e.t.c
How can I reduce things I don't need ?
Thanks
Without actually compiling the code (see my final paragraph...), you might not even need the safari permutation, but might get by with no UserAgent wiring at all. You could experiment with your inherits statements, and see if you can remove User, and only depend on com.google.gwt.core.Core from the main portion of GWT itself. This at least will remove the user agent parser (which is there to confirm that you aren't accidentally running the safari permutation in IE, for example). Alternatively, you can disable that runtime check: <set-configuration-property name="user.agent.runtimeWarning" value="true"/> If you go this route, also consider disabling the document mode check, another piece of GWT sanity check that happens on startup: <set-configuration-property name="document.compatMode.severity" value="IGNORE" /> -- Your code looks like it might be a stripped down version of something more interesting that you will write later, but if it turns out that you will be keeping it that simple, consider turning off stack trace emulation. It doesn't actually _entirely_ remove the stack trace collection code (I'm actually already looking into how to fix this), but it does minimize what is needed for your app to turn on. The three values are native, emulated, and strip: native assumes that browser provides some ways to read the stack already, emulated bakes in a ton of extra debug information into your compiled sources, and both of them review and attach that information to java Exceptions. Strip, on the other hand, does nothing except fill the collector-shaped hole so that the rest of GWT believes everything is working correctly: <set-property name="compiler.stackMode" value="strip" /> -- Much of what remains is various Java emulation for types (including some which are incorrectly not pruned, like ClassCastException in an app which can't throw such an exception). There isn't a lot in 2.8 that can be done to remove that code, but for any code more interesting than creating a single object and attaching it to the window it will be required to behave like proper Java. -- After compiling a trivial GWT app (native window.alert from entrypoint) I don't get any code adding a window listener. I also am not seeing JsGlobals.getWindow() anywhere in either 2.8 elemental nor elemental2-experimental 16-06-30. Where is that coming from, and is there any chance that it has static setup code that wires up the listener?
<set-configuration-property name="user.agent.runtimeWarning" value="false"/>
did the job, and removed "$wnd.setTimeout($entry(assertCompileTimeUserAgent));" at the entry point.
But document.compatMode.severity=IGNORE did not change anything in code generation, it still generates
severity = ($clinit_DocumentModeAsserter$Severity() , IGNORE);
if (severity == IGNORE) {
return;
}
It is unclear for what reason GWT generates (and never uses in the generated code):
if (!$wnd_0.__gwt_stylesLoaded) {
$wnd_0.__gwt_stylesLoaded = {};
}
if (!$wnd_0.__gwt_scriptsLoaded) {
$wnd_0.__gwt_scriptsLoaded = {};
}
It also would be very nice to remove that:
function isHostedMode() {...} if (isHostedMode()) { alert(...); }
And I see a lot of never used variables in the generated code, ex:
var Lcom_google_gwt_core_client_impl_SchedulerImpl_2_classLit = createForClass(22);
var onBodyDoneTimerId = setInterval(function () { ....
var $gwt_version = "2.8.0";
var $stats = $wnd.__gwtStatsEvent ? function (a) { ....
var $strongName = '6D7BE6648CA01BEDC1B199CE04D6BBCD';
var Lcom_google_gwt_core_client_impl_StackTraceCreator$Collector_2_classLit = createForClass(37);
var Lcom_google_gwt_core_client_impl_StackTraceCreator$CollectorLegacy_2_classLit = createForClass(18);
var Lcom_google_gwt_core_client_impl_StackTraceCreator$CollectorModern_2_classLit = createForClass(19);
Is it an issue that the GWT generates never-used variables ?Thanks
FYI: https://plus.google.com/+RayCromwell/posts/VK8URgZiLbS