2 ms·
It is actually possible to use Brotli directly in the web browser... with caveats of course. I believe my 2022 submission to JS1024 [1] is the first ever demons
by lifthrasiir 2y ago
It is actually possible to use Brotli directly in the web browser... with caveats of course. I believe my 2022 submission to JS1024 [1] is the first ever demonstration of this concept, and I also have a proof-of-concept code for the arbitrary compression (which sadly didn't work for the original size-coding purpose though). The main caveat is that you are effectively limited to the ASCII character, and that it is highly sensitive to the rendering stack for the obvious reason---it no longer seems to function in Firefox right now.
[1] https://js1024.fun/demos/2022/18/readme https://js1024.fun/demos/2022/18/readme
[2] https://gist.github.com/lifthrasiir/1c7f9c5a421ad39c1af19a9c4f060743 https://gist.github.com/lifthrasiir/1c7f9c5a421ad39c1af19a9c...
- purplesyringa 2y agoThis technique is amazing and way cooler than my post. Kudos!
- zamadatix 2y agoThe key note for understanding the approach (without diving into how to understand it's actually wrangled): > The only possibility is to use the WOFF2 font file format which Brotli was originally designed for, but you need to make a whole font file to leverage this. This got more complicated recently by the fact that modern browsers sanitize font files, typically by the OpenType Sanitizer (OTS), as it is very insecure to put untrusted font files directly to the system. Therefore we need to make an WOFF2 file that is sane enough to be accepted by OTS _and_ has a desired byte sequence inside which can be somehow extracted. After lots of failed experiments, I settled on the glyph widths ("advance") which get encoded in a sequence of two-byte signed integers with almost no other restrictions. Fantastic idea!
- lifthrasiir 2y agoCorrection: It still works on Firefox, I just forgot that its zoom factor should be exactly 100% on Firefox to function. :-)