WOFF2 to self-extracting HTML brotli compressor thingy for code-golfing competitions
- Install NodeJS
- Put a txt file to compress in the same folder as the repo files (ex: test.txt).
- Your txt file must be a JS script.
- Run
node packer.js test.txt test.html
- The script compresses your txt file using the power of Brotli's dictionnary (and Brotli's advanced compression levels).
- The compressed code can't be read directly by the browser, so it's embedded in a WOFF2 file (which supports Brotli compression).
- A HTML file is generated, which is a self-extracting WOFF2 file.
- When you open the HTML file in the browser, the contents of the txt file is evaluated.
- WOFF2 garbage is also displayed in the browser, but you can use JS or CSS to hide it.
- In many cases, the compression is much better than simply zipping the txt file (ex: test.txt becomes a 1.9kb file with this and 2.3kb with zip only).