Browsers do not give access to javascript about how much of a certain
resource has been loaded. Ignore Carl Scott's comment, I think he
doesn't realize we're talking about a progress bar for GWT itself
instead of a generic progress bar.
Javascript in general doesn't run incrementally, so having the actual
GWT data generated by the gwt compiler emit progress bar updates won't
work.
The only way I can think of is:
1. Browser first opens an XML-HTTP connection before actually getting
the gwt datafile in order to receive a cookie from the server. Let's
call it the 'downloadId'.
2. Browser now gets the GWT datafile. Server knows the downloadId as
its sent along in a cookie.
3. Browser, in tandem with the download (by using XML-HTTP requests
for example), opens a second connection to the server to ask how far
the download for 'downloadId' has progressed so far. This number is
somewhat flaky (who knows how much caching has been done by
intermediate routers and proxies?) but in general is a good reflection
of % downloaded. The browser will re-open this query (how far is
download for 'downloadId') every 500 msec or so.
It would work. It's also utterly infeasible:
1. The slower the connection, the more important that loading bar is.
However, the slower the connection, the slower the response will be to
the second request. You'll also be delaying the download because
packets are being 'wasted' giving progress reports.
2. This requires considerable logistics on the server side. GWT is
currently server-agnostic, aside from GWT-RPC. GWT would have to ship
a 'download' library for a big host of web frameworks.
3. In order for the server to measure progress, the download has to
be handled by a servlet (or the equivalent in other web frameworks).
For most web frameworks, letting apache (or the core webserver if it's
not apache) handle big files is way more efficient than letting code
do it. Making all gwt data file downloads be handled by a servlet
probably means your server triples its CPU usage. Just to handle
progress reports. Ick.
A tactic which could be slightly more reasonable is the following:
Right now the gwt data file is just one giant obfuscated JS blob which
is imported via the dynamic creation of a script src= tag. You could
instead grab the data via XML-HTTP, and eval() it. eval() code is slow
code in many JS engines, which is the major roadblock here. However,
you could also hash up the downloaded stuff which has benefits for
e.g. speeding up https (by downloading the core gwt files over http,
enabling caching, but still having security in place by checking the
hash of the downloaded-over-http material with a downloaded-over-https
hash). This XML-HTTP download could be split up into blobs of, say,
20k each, where after each blob has been downloaded, you 1) update the
progress bar, and 2) fire up the request for the next blob.
With some effort you can split on the nearest JS parsing boundary
closest to the next 20k mark, and use multiple script src= tags,
eliminating the slowdown caused by using eval(), though you'd lose the
https speedup thing.
This is possibly feasible (though you'd need to do a little more
research). It's also a boatload of work. You'd have to dive into the
GWT Compiler innards and completely rewrite the gwt bootstrapper.
I doubt any core contributor is going to do it, so if it is going to
be done, you'll have to, and submit a patch.