← notes

Optimising inside a build environment that forbids plugins

Jul 22, 2017

A Jekyll blog for bitcoin development writing, with a Sass tree, a projects data file, and one post reviewing SegWit2x.

The file worth a note is _layouts/compress.html, the Liquid trick for stripping whitespace from generated HTML. It wraps the rendered output and removes newlines and indentation at template level, with no plugin and no build step.

On GitHub Pages that is not a preference. Pages runs Jekyll in safe mode with a fixed plugin whitelist, so anything that would normally be a plugin has to happen inside the template language or not at all. That constraint is the interesting part: a restricted build environment does not remove the desire to optimise, it pushes optimisation into whatever layer is still available, and the results are inventive and slightly unhinged. Whitespace removal implemented in a templating language is a good example of both.

It needs care around significant whitespace, since content inside <pre> and <textarea> must survive intact, and getting that wrong on a technical blog full of code samples is immediately visible.

_data/projects.yaml driving a page from structured data rather than hand-written markup is the other habit worth keeping, and the thing Jekyll is genuinely good at.

One post, and the compress layout outlived the writing.