rich Posted July 11, 2013 Share Posted July 11, 2013 lz-string was designed to fulfill the need of storing large amounts of data in localStorage, specifically on mobile devices. localStorage being usually limited to 5MB, all you can compress is that much more data you can store. http://pieroxy.net/blog/pages/lz-string/index.html Quote Link to comment Share on other sites More sharing options...
Chris Posted July 11, 2013 Share Posted July 11, 2013 What would you want to store in localStorage where 5MB (!) isn't enough? Quote Link to comment Share on other sites More sharing options...
xerver Posted July 11, 2013 Share Posted July 11, 2013 What would you want to store in localStorage where 5MB (!) isn't enough? Saved game states, replay data, caches for offline experiences, editor data (for like a world editor), etc. Quote Link to comment Share on other sites More sharing options...
rich Posted July 11, 2013 Author Share Posted July 11, 2013 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. Quote Link to comment Share on other sites More sharing options...
Ezelia Posted July 12, 2013 Share Posted July 12, 2013 Excellent ! was looking for something like that last week @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 ...etcfor 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 Quote Link to comment Share on other sites More sharing options...
Chris Posted July 20, 2013 Share Posted July 20, 2013 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! Quote Link to comment Share on other sites More sharing options...
Wenbuyi Posted September 13, 2015 Share Posted September 13, 2015 i find a free online js compressor service to compress your js code, so it will reduce the size of web page. Quote Link to comment Share on other sites More sharing options...
WombatTurkey Posted November 19, 2015 Share Posted November 19, 2015 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.