- Code by Senokay / Lifthrasiir (see https://gist.github.com/lifthrasiir/1c7f9c5a421ad39c1af19a9c4f060743)
- More info in his epyt game (see https://js1024.fun/demos/2022/18/readme)
- Full brotli's dictionnary: https://gist.github.com/klauspost/2900d5ba6f9b65d69c8e
- 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).