This post is over 6 months old. Some details, especially technical, may have changed.

Announcing Baler

It's very early days (with regards to both code and documentation) but I though I amy as well put it out there.

Baler is a .NET Web Resource Bundler. Capable of concatenating and transforming CSS and JavaScript files to lower request count and bandwidth requirements. It works with any .NET Web Framework/View Engine capable of running C# in the view

What differentiates Baler from other resource bundlers out there is that it aims to provided a bare bones, minimum feature set for building bales (or resource bundle). The core Baler package offers the ability to concatenate, render and cache JavaScript and CSS bales. Thats it. No minification nor fancy processing nothing. However Baler does have 2 main extensibility hooks though (Before and After) which can be leveraged to control how bundles are manipulated. There are currently 3 extensions for Baler but more are on their way,

  1. CoffeeScript - Transforms CoffeeScript files into JavaScript
  2. .LESS - Transforms .LESS files into CSS
  3. Ajax Minifier - Allows for minification of JavaScript and CSS using Microsofts Ajax Minifier

Quick Example

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="CodeSlice.Web.Test.Default" %>
<%@ Import Namespace="CodeSlice.Web.Baler" %>

<!DOCTYPE HTML />
<html>
  <head>
    <%=
      Baler.Build(
        "~/scripts/script1.js",
        "~/scripts/script2.js",
        "~/scripts/script3.js",
      ).AsJs()
    %>
  </head>
  <body>
  </body>
</html>

This example will take 3 source files concatenate them into a random script file and output the necessary <script src='1jdk2ds.js' type='text/javascript'></script>. Subsequent calls that match this bales signature (the order and contents of the bale) will use the cached script tag and not perform that concatenation again.

As I say it's early days. I really need to get the docs up to snuff, write plenty of test and add a few more features before I start shouting from the rooftops but at least it's out now and there is no going back :-).

Baler v0.1 is available on Nuget and Github and the annotated source code is available here, here, here and here

Published in .NET on May 30, 2011