Jump to content

lz-string: JavaScript compression, fast!


rich
 Share

Recommended Posts

Granted I expect it's not that common, but proper RPG progress stats, encounter history, inventory, character stats etc spread over multiple save games slots? Anything where you generate custom worlds/environments/3D object data and don't want to save it to a server could crank up quickly too. I've often wondered if you could store actual game data there as well, i.e. use it as an offline cache for texture data and the like, so you don't need to pull it over the network next time you play it. But that's a bit of an edge case I guess.

Link to comment
Share on other sites

Excellent ! was looking for something like that last week :D

@Chris : in my case I want to use localstorage to save an RPG game state, this include hero state, inventory, quests plus some cached data like game maps ...etc

for example, for my game maps, I allways use Tiled Editor, I noticed that Tiled JSON output compress very fine with lz-string ... in my game, maps are about 32k vs 8k compressed in lz-string (12ms to compress / 6ms to decompress)

with lzma they are smalled 4k compressed size but it takes 800ms to compress / 90ms to decompress.

all in all, it definitely worth it :D
 

Link to comment
Share on other sites

  • 2 weeks later...
  • 2 years later...
  • 2 months later...

I would recommend only using this on the clientside, it hurts node's event loop far too much.

 

 

I think I am implementing this lib when sending large chunks of JSON data back to the server.

Before compression, i have ~75000 bytes, after applying the LZMA compression, its only ~6400 bytes!

 
I've done tests similar to this when sending inventory data over the websocket pipe (same data type as you, json) and it was only 2000 bytes, but the time it took to send was increased by almost 100ms and hurt nodes event loop (not sure if you're doing it under node -- and it just wasn't worth it. Seemed cool at first, but the compression does take its tole. I chose to rather not use it, but only w/ clientside stuff.

 

Just a heads up from my personal experience :)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...