0

I find generated .js file is long and large after Dart2JS. I am using pub build on dart editor not include Angular/Polymer packages. Some files xxxx.dart.precompiled.js arround 1500 - 2500KB.

I want to know if Dart provide any way to compress and obfuscate javascripts when Pub build?

Günter Zöchbauer
  • 623,577
  • 216
  • 2,003
  • 1,567
Roger Chan
  • 1,293
  • 2
  • 11
  • 24
  • You don't provide much information. Do you use Angular, Polymer, .... What kind of project do you have. How do you build to JS? `pub build`, `pub build --mode=release`, `pub build --mode=debug`, ... ? How big are the generated files? – Günter Zöchbauer Sep 03 '14 at 05:05
  • I am using pub build on dart editor and not include Angular/Polymer packages. Some files xxxx.dart.precompiled.js arround 1500 - 2500KB. – Roger Chan Sep 03 '14 at 05:40
  • Please try `pub build --mode=release` on the command line and update the output size. I don't know which arguments DartEditor uses by default. – Günter Zöchbauer Sep 03 '14 at 05:41
  • Size is reduced to arround 700 - 1000KB by using "pub build --mode=release" instead of "Pub build" in editor. – Roger Chan Sep 03 '14 at 06:24
  • I guess this is as low as it gets. You can gzip it and you should reach about 200k that actually need to get over the wire. – Günter Zöchbauer Sep 03 '14 at 06:26
  • If you add the additional information you provided in comments to your question I can remove the downvote. – Günter Zöchbauer Sep 03 '14 at 06:56
  • When you run `pub build --mode=release` tree-shaking and minification is done. For the actual compression you need other tools. See http://betterexplained.com/articles/how-to-optimize-your-site-with-gzip-compression/ for example. Dart is known for its bigger initial output size (for a hello world sized app) but additional custom code doesn't add that much afterwards. Dart includes a lot of functionality you would have to add several libraries for in JavaScript. – Günter Zöchbauer Sep 03 '14 at 08:49
  • The output size seems too big. Maybe you're using mirrors? What are all the packages that you are using? Can you put your pubspec.lock into a Gist and put the URL here? That would help. Also, run dart2js --dump-info and input into https://dart-lang.github.io/dump-info-visualizer/build/web/viewer.html – Seth Ladd Sep 03 '14 at 19:51

0 Answers0