Showing posts from January, 2013

Minification is not enough, you need tree shaking

In which the virtues of automated mechanical arboreal pruning are extolled over quaint manual labor, as applied to web development build processes. The setup Ever notice how the primary bit of marketing for many traditional web programming libraries is their download size? Why is that? Check this out: Why does size matter so much for these libraries? Your first instinct is probably, "because the more bytes you shuttle across the wire, the slower the app starts up." Yes, this is true. I'd also say you're wrong. The primary reason that size matters for these libraries is because traditional web development has no intelligent or automated way to prune unused code  so you can ship only the code that is used over the wire. The web is full of links, yet web dev has no linker The web development workflow is missing a linking step. A linker's job is to combine distinct project files into a single executable. A smart linker will only incl

Holy Cow, Dart Unit Tests are Easy

Dart provides a rich unit test library out of the box. Inspired by testing libraries like Hamcrest and dartmatch , the dart:unittest library provides test groups, numerous matchers, and more. Read on to learn how easy it is to write your first Dart unit tests! You, too, can create tests this pretty. Test subject To illustrate, I've just created the soon-to-be massively critical embiggen library. This library will bigify your text. It's very advanced. Of course, I made a pub package for this library: The contents of embiggen.dart are: library embiggen; String embiggen(String msg) { if (msg == null) { throw new ArgumentError("must not be null"); } return msg.toUpperCase(); } I'll let that sink in for a while, it's pretty intense. Add the unit test package You can use pub to get the unit test package and link it into your project. Simply declare the unittest dependency in your pubspec.yaml: nam

Do This One Thing Or Your Dart Web App Will Break

This is not link bait, this is a serious call to action for our Dartisans. If you do nothing, your Dart web app will stop working in a few weeks. Luckily, the fix is easy. To learn how to keep your Dart web app working, read on! Background Almost all Dart web apps use a small, but crucial, JavaScript file to bootstrap. While strictly not required, this dart.js file contains the necessary logic to turn on the Dart VM, swap out Dart code for JavaScript code if the VM isn't available, enable Dart-JavaScript interop, and more. Most Dart web apps have this line at the bottom of their HTML file: <!-- Don't do this anymore, for illustrative purposes only --> <script src=""></script> The Problem There are a few problems with the current arrangement. The Google Code SVN server is not a CDN, and is not optimized for acting as a CDN. Relying on a public HTTP