lz-string icon indicating copy to clipboard operation
lz-string copied to clipboard

LZ4 compared to LZ-string ?

Open Extarys opened this issue 5 years ago • 3 comments
trafficstars

There are some nice benchmark for LZ4 here but I'm not a pro of compression.

I'm looking for a way to store objects for a web extension and since lz-string was primary developed for this, I'm tempted to use it, but I was wondering if there was a good point in using lz4 (wasm)?

Extarys avatar Dec 31 '19 23:12 Extarys

LZ-String is specifically tailored to compress a string into another string, making the best use of the UTF-16 encoding. If you can store other type of data (uint8array, etc.) then it makes sense to use a library that will return this kind of data.

LZ4 should provide the same compression level but should be much faster.

pieroxy avatar Aug 13 '21 06:08 pieroxy

@pieroxy

My question is if you plan to release the 15bit character encoding as a separate project? How hard would it be?

As you noted on your page some browsers might have problems with arbitrary 16bit characters shoved into localStorage. This library solves that problem but only for the current compression algo.

A more general solution would be welcome to allow any binary data to be efficiently stored into such places with your excellent 15bit encoding. This would work well with other compression outputs and even binary images.

Yes there are other solutions for binary data (like IndexDB) but I found that some browsers (e.g. Safari) have way better performance when reading from localStorage during the initial rendering of the page. So for first paint critical resources this would be very helpful.

gblazex avatar Jan 12 '22 21:01 gblazex

I found a library for it

https://github.com/qntm/base32768/

gblazex avatar Jan 13 '22 08:01 gblazex