Back to browse
JavaScript/JSON and CSS minifier lib in minimal C89

JavaScript/JSON and CSS minifier lib in minimal C89

by sgbeal·Jul 27, 2026·1 point·0 comments

AI Analysis

●●SolidCozyNiche Gem

Hand-written CSS minifier paired with an LLM-generated JS counterpart in pure C89.

Strengths
  • Strictly C89 compliant with zero external dependencies beyond the standard library.
  • Streaming API handles input/output via abstract I/O functions for maximum flexibility.
  • Constant memory usage storing only previous two bytes, avoiding dynamic allocation.
Weaknesses
  • Minifies spaces only, lacking symbol reordering or advanced compression techniques.
  • LLM-generated JS component required manual fixes for nested comments and bogus asserts.
Target Audience

Embedded developers, C programmers, and minimalists avoiding Node.js dependencies

Similar To

terser · csso · minify

Post Description

For those 1.7 of you who may have need of a JavaScript or JSON minifier which (A) is not based on node.js and (B) is not "poisoned" by the "do no evil" license attached to Douglas Crockford's minifier (commonly seen in various projects over the years)...

My C89 CSS minifier was recently broken down into a separate JavaScript/JSON minifier. It's trivial to embed in C, "should" build fine in WASM (that's untested, though), and is pretty small: the whole combined library is about 67kb, or about 34kb for just the JS parts (much of which is docs).

It minifies only spaces, not symbols, and does not offer any options for _not_ minifying (e.g. adding newlines every so often for the sake of tools which treat extremely-long-lined files as binaries) except that by default it retains the first comment in the input if it's the first non-whitespace content (those are typically license/attribution blocks) but it can be told to optionally strip those too.

LLM disclaimer: the 100% hand-written CSS minifier was given to an LLM which, tasked with creating a JS minifier with the same interface, created the new variant in about 20 seconds. That code was later hand-refactored to consolidate parts common to the two minifiers (all of which were hand-written) but the JS-specific pieces are otherwise 100% LLM-generated.

Happy minifying!

Similar Projects

AI/MLMid

PicoGPT – GPT in a QR Code

The author minified Karpathy’s MicroGPT, ported it to 39 lines of JS (including a tiny autograd, MHA, AdamW and training loop) and shoehorned the whole gzipped HTML into a version-40 QR code that the browser decompresses and runs. It's clearly a stunt — the model is toy-scale (≈4k params, 8-token context) — but the compression trick, browser-native DecompressionStream use, and runnable-in-QR delivery are a delightful technical flex.

WizardryCrowd Pleaser
kuberwastaken
105mo ago