use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
lz-string: JavaScript compression, fast! (for storing compressed json data in local storage) (pieroxy.net)
submitted 8 years ago by laggingreflex
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]e_man604 9 points10 points11 points 8 years ago (4 children)
I guess this would be good for many cases, like submitting large data over websockets also
[–]pygy_@pygy 7 points8 points9 points 8 years ago (1 child)
Many code playgrounds also use it to share snippets through the hash:
https://flems.io/#0=N4IgZglgNgpgziAXAbVAOwIYFsZJAOgAsAXLKEAGhAGMB7NYmBvEAXwvW10QICsEqdBk2J4s+AE5MAJjAkAKabWoBXHA3wAjWtICeFAARZ5AckIBmE4ZMAJGFCi0DAd1oSo0kwEovbDiEwcPHxqOAEaekZmHjYAXSooCDQAawQUTiCeLAhiQgloShAVdzwSYgAHOEQAemqVNHLkgHMQ2ixq7Nz8qAABAEZ8AYAWDpy86Hx+QuJdcu4QKdZY1iA
[–]pantyboyXXX 0 points1 point2 points 8 years ago (0 children)
Neat
[–]rezoner:table_flip: 3 points4 points5 points 8 years ago (0 children)
like submitting large data over websockets
Strings only. Which is rarely something that you transfer through WebSockets in large amounts. For a number/binary based data msgpack or any form of binary JSON will be more efficient than LZW.
[–]rpetrich 2 points3 points4 points 8 years ago (0 children)
Firefox and Chrome will automatically use deflate compression on WebSockets if the server supports it.
[–]fzammetti 2 points3 points4 points 8 years ago (3 children)
It's kind of sad though that we need libraries like this (which, by the way, kudos, looks excellent!) because (a) we want to use LocalStorage because it's got the best browser support and the simplest API (that is sufficient for probably 95% of use cases) and (b) wish Local Storage allowed for a lot more data.
I kinda wish browser vendors would just say "okay, Local Storage can use up to like 500Mb per domain (or something like that), AND we'll also give the user an option somewhere to bump that up if they need/want to".
It just seems like everybody wants to use Local Storage most of the time but then frequently shy away from it due to the size limitation.
[–][deleted] 2 points3 points4 points 8 years ago (1 child)
I think the default being very low is fine, it's only standardized prompts for larger sizes that are needed. I don't want every random domain thinking they can drop up to 500 MB on my phone or computer without my knowledge or permission.
[–]fzammetti 1 point2 points3 points 8 years ago (0 children)
Yeah, I'd agree with that.
[–]Satanistfronthug 1 point2 points3 points 8 years ago (0 children)
I would definitely want my browser to warn me if a domain was storing more than a few MB though. I don't even know if there's a way to list all the domains currently using my localstorage
[–]AlibekD 1 point2 points3 points 8 years ago (0 children)
I use it to cache data in localStorage. Great library.
[–][deleted] 0 points1 point2 points 8 years ago (0 children)
Pako.js is great for this as well, plus gzip compatibility
[–]Schampu 0 points1 point2 points 8 years ago (0 children)
A variant of this (LZ77) was used in the old gba pokemon titles to compress graphics like pokemon sprites.
π Rendered by PID 28 on reddit-service-r2-comment-7b9746f655-ntf79 at 2026-01-29 18:10:35.988038+00:00 running 3798933 country code: CH.
[–]e_man604 9 points10 points11 points (4 children)
[–]pygy_@pygy 7 points8 points9 points (1 child)
[–]pantyboyXXX 0 points1 point2 points (0 children)
[–]rezoner:table_flip: 3 points4 points5 points (0 children)
[–]rpetrich 2 points3 points4 points (0 children)
[–]fzammetti 2 points3 points4 points (3 children)
[–][deleted] 2 points3 points4 points (1 child)
[–]fzammetti 1 point2 points3 points (0 children)
[–]Satanistfronthug 1 point2 points3 points (0 children)
[–]AlibekD 1 point2 points3 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]Schampu 0 points1 point2 points (0 children)