pieroxy / lz-string

LZ-based compression algorithm for JavaScript

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

LZ4 compared to LZ-string ?

Extarys opened this issue · comments

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)?

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

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.