This blog is a static site generated by Wyam. Unfortunately, while Wyam includes a minification library, out of the box Wyam doesn't minify any of the files it generates. However, it's very extensible and makes it easy to add or modify pipelines.

Starting with the Blog recipe, modify the config.wyam file to include the minification Nuget package, Wyam.Minification by adding it to the list:

#n Wyam.Markdown

#n Wyam.Minification

#n Wyam.Razor
#n Wyam.Yaml
#n Wyam.TextGeneration

The Minification package makes modules to minify CSS, HTML, JavaScript, XHTML, and XML available to use. The first thing to minify are the CSS files. Normally, the Resources pipeline uses the CopyFiles module to copy stylesheets without modification. This can be left in place, as it's more trouble to modify it than it's worth. Instead, add a new pipeline called MinifyCSS:

Pipelines.InsertAfter
(
    "Resources",
    "MinifyCSS",
    ReadFiles("**/*.css"),
    MinifyCss(),
    WriteFiles(".css")
);

That creates the pipeline and inserts it to be executed after the Resources pipeline. The order is important, as otherwise Resources would overwrite the minified files with the originals. The rest is fairly self explanatory.

Next to minify the JavaScript. This turns out to be an almost identical process to CSS minification, except .js files are specified and the MinifyJs module is used:

Pipelines.InsertAfter
(
    "Resources",
    "MinifyJS",
    ReadFiles("**/*.js"),
    MinifyJs(),
    WriteFiles(".js")
);

Now that the resources are minified, the actual HTML pages come next. This turns out to be even simpler in most cases, since it doesn't need a new pipeline, only a new module added to an existing pipeline:

Pipelines["RenderBlogPosts"].InsertBefore
(
    "WriteFiles",
    "MinifyHtml",
    new MinifyHtml()
);

This adds a module named "MinifyHtml" to be executed right before we write the files. Do the same for the RenderPages, Index, and Tags pipelines:

Pipelines["RenderPages"].InsertBefore
(
    "WriteFiles",
    "MinifyHtml",
    new MinifyHtml()
);

Pipelines["Index"].InsertBefore
(
    "WriteFiles",
    "MinifyHtml",
    new MinifyHtml()
);

Pipelines["Tags"].InsertBefore
(
    "WriteFiles",
    "MinifyHtmlTags",
    new MinifyHtml()
);

Update 2019-01-18:

With that, most of the pipelines are minifying their output. However, two of them, TagIndex and BlogArchive, require a different approach due to the fact that they are executed conditionally. Luckily, Wyam 2.1.2 makes this much easier than before. This makes adding MinifyHtml to the TagIndex and BlogArchive Pipelines much easier than before:

((IList<IfCondition>)Pipelines["TagIndex"].GetFirst<If>())[0].InsertBeforeFirst<WriteFiles>
(
    new MinifyHtml()
);
((IList<IfCondition>)Pipelines["BlogArchive"].GetFirst<If>())[0].InsertBeforeFirst<WriteFiles>
(
    new MinifyHtml()
);

The type casting makes it a bit messy, but is otherwise fairly simple.

Update 2019-01-31

Wyam 2.1.3 lets us deal with this even more simply by removing the need to type cast:

Pipelines["TagIndex"].GetFirst<If>()[0].InsertBeforeFirst<WriteFiles>
(
    new MinifyHtml()
);
Pipelines["BlogArchive"].GetFirst<If>()[0].InsertBeforeFirst<WriteFiles>
(
    new MinifyHtml()
);

In total, minifying the original Part 1 shaved off 14% of the size of the HTML + CSS. However, ociaw.com is intentionally simple and minimalistic, so bigger gains could be realized if a heavier website is minified. There's still room for improvement, however since SVG files, the RSS/Atom feeds, and the sitemap can all be minified as well.