O'Reilly logo

Dart: Scalable Application Development by Ivo Balbaert, Sergey Akopkokhyants, Davy Mitchell

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Shrinking the size of your app

On the web, the size of the JavaScript version of your app matters. For this reason, dart2js is optimized to produce the smallest possible JavaScript files.

How to do it...

When you're ready to deploy, minify the size of the generated JavaScript with –m or -- minify, as shown in the following command:

dart2js –m -o prorabbits.js prorabbits.dart

Using pub build on the command line minifies JavaScript by default because this command is meant for deployment.

How it works...

The dart2js file utilizes a tree-shaking feature; only code that is necessary during execution is retained, that is, functions, classes, and libraries that are not called are excluded from the produced .js file. The minification process further reduces ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required