Mats Bryntse
1 April 2018

Speeding up our releases by writing minified code

A few months back we achieved a nice speed boost of our release procedure, and today we’re happy to share […]

A few months back we achieved a nice speed boost of our release procedure, and today we’re happy to share with you how we did it. As part of every nightly build and release, we run a minify step that minifies all our CSS and JS resources. This step typically takes around 10 seconds depending on the size of the resource being minified. In our new and improved build process, we no longer require this minifying step. How did we do it? By writing minified code.

Less is more

We realized that if we write code in the minified format produced by our minifying tool, we could skip the minification script completely. Instead of having a verbose, disk space consuming code format such as:

findClosestSuccessor: function(event, events) {
    var timeAxis = this.timeAxisViewModel.timeAxis,
        tickIndex = Math.floor(timeAxis.getTickFromDate(event.start)),
        tick = timeAxis.getAt(tickIndex);

    for (var i = 0, length = events.length; i < length; i++) {
        if (events[i].start >= tick.getEndDate()) {
            return events[i];

…we could optimize things and instead write things in a more compact way. We call this new methodology Minification Driven Development™. With MDD, you just write the above in one line (saving tons of screen real estate):

findClosestSuccessor:function(e,b){var c=this.timeAxisViewModel.timeAxis;var d=Math.floor(c.getTickFromDate(e.start));var f=c.getAt(d);for(var a=0,g=b.length;a<g;a++){if(b[a].start>=f.getEndDate()){return b[a]}}}

Using the MDD code style brings numerous advantages:

After introducing this new way of coding, developers now feel much more fresh and energized during work hours as they are typing less and reading less. The numbers back it up too, according to a recent employee satisfaction report we did – our staff is clearly more happy when typing less.


This sounds too good to be true, any drawbacks?

The only slight drawback we’ve noticed is that understanding the intent of the minified code is a bit harder. Usually though, you can kind of understand what the code is doing and worst case you can just guess and hope for the best, which works most of the time. Sort of.

What are your favorite tips & tricks to keep your developers motivated? Please let us know!

Mats Bryntse

Company updates Tips 'n tricks