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 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:

  • Less keyboard wear and tear since we hardly ever use annoying keys like ENTER or SPACE
  • Less typing, saving precious finger energy for our developers
  • Less characters to read, increasing speed of reading
  • Faster build, no need for fancy minifying tools – saving 10 seconds on every build
  • More code fit on the screen. With regular code formatting, reading a 3000 line function is hard due to all the
    white space and comments. With the minified format, you can see the entire function in view.

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.

chart

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!

Comments ( 3 )

  • Easter bunny

    This is a joke right?

    • Mats

      You’ll have to download next release and see for yourself 🙂

Leave a Comment