Code Splitting in GWT
A pain point for Google web applications is the time required to
download the JavaScript code that supports them. Web pages do not
become interactive until the supporting JavaScript code has downloaded
and been parsed. Moreover, the amount of JavaScript code trends upward
over the lifespan of an app, because developers add more features and
those features require more code to support.
To address this, I extended
the Google Web Toolkit to
support code splitting. Some notable aspects of the project:
- It splits the code without respecting module boundaries, so that
developers can start using it without having to reorganize their
entire application according to the deployment strategy. This feature
was crucial for adoption, because developers never start code
splitting until their app has grown large enough to require
it. Serious development tools should never force developers
to rewrite
from scratch.
- I developed debugging debugging support based on the
GWT Compile
Report. Any whole-program optimization has the downside that
changes by a developer have non-local effects. Whenever the
whole-program optimization cannot be avoided, it is important to
provide tool support for tracing the effects of those changes.
- I developed and documented techniques for evolving a code base to
minimize the non-local effects on the code splitter. In particular, I
developed the
Async
Provider pattern to help control where lazy-loaded code is
accessed synchronously.
The GWT code splitter is used
by Google Adwords
and Google Wallet, among many
other web applications.
See the
GWT code splitter documentation for more information.
Lex Spoon