New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable dart2js to split output into N files to reduce initial download size #3940
Comments
Added Area-Dart2JS, Triaged labels. |
Added this to the Later milestone. |
Removed this from the Later milestone. |
Added this to the Later milestone. |
Set owner to @peter-ahe-google. |
Removed Priority-Medium label. |
Progress so far: API proposal for deferred loading: https://codereview.chromium.org/11784018/ Compiler API changed to support multiple output files using Sinks/Streams (committed r17749). Implemented deferred loading of static/top-level functions: https://codereview.chromium.org/12033003/ Missing: deferred loading of classes. |
Added Started label. |
I have landed the CL with the API (r18637), and the CL for deferred loading of static/top-level functions (r18671). I'm still working on deferring load of classes. |
Thanks, where is this documented? A quick check of the spec didn't come up with anything. |
There is a new class called DeferredLibrary in dart:async. I don't know where to find up-to-date bleeding_edge documentation, so I cannot give you a link to it. But this feature is nowhere near complete, please don't announce anything yet. |
For those following along at home: http://api.dartlang.org/docs/bleeding_edge/dart_async.html Don't worry, just following along. Excited! |
https://codereview.chromium.org/12224010 implements deferred loading of classes. I'm aware of the following major short-comings that will persist after CL 12224010 is landed: * The deferred code will often force Isolate.prototype to become a "slow" object. This means that calling top-level or static methods that have been lazily loaded becomes really slow (this also applies to Dart constructors). * Only the library that is marked with DeferredLibrary is deferred. Instead, we need to perform something like tree-shaking to ensure that stuff only used by the the deferred library doesn't get included in the main JS file. * Constants using deferred classes are broken. * You can split the output in at most two files. All these limitations are short-term, and I'm working on eliminating them. However, I think that once CL 12224010 lands, people can start using this for real apps. |
Deferred loading of classes landed in r18834, and deferred loading of constants landed in r19378. I'm currently working on computing the transitive closure of deferred libraries to ensure that the initial download doesn't include stuff only needed by a deferred library. |
https://codereview.chromium.org/12525007/ implements basic dependency graph segmentation. This means that the initial download should not be polluted with unneeded code from shared libraries. |
Submitted CL 12525007 as r19793. The compiler will now segment the dependency graph. This should make the initial download much smaller. |
Added C1 label. |
This comment was originally written by @seaneagan The "You can split the output in at most two files" limitation is what I am hitting right now. I am trying to split it into about 170 files. My code is at: https://github.com/seaneagan/intlx/blob/master/lib/src/plural/load_locale.dart Each of the 170 correspond to libraries which contain plural rules code for given locales from this directory: https://github.com/seaneagan/intlx/tree/master/lib/src/plural/locale Will this amount of files ever be possible/performant? If yes, I'll create a separate issue to track support for more than 2 files. If no, that would be a regression from JavaScript, where this is commonly done. |
This issue was originally filed by andreb...@gmail.com
When using dart2js the generate javascript contains everything required to run the code, but sometimes the application don't need to use the entire code to execute.
An example:
mainPage:
load the std library and mainPage.dart
configPage:
load only the configPage.dart code and use the rest that was loaded
in the mainPage
The idea is to have something similar to what is done in GWT (with runAsync) and closure-compiler (with modules).
The text was updated successfully, but these errors were encountered: