inherit
173855
0
Apr 23, 2024 9:59:44 GMT -8
Texas
I check in every once in a while...
869
November 2011
petermaggio
|
Post by Texas on Sept 1, 2015 17:58:12 GMT -8
I'm debating a substantial re-write to my {username} to @ username plugin. I'm just wondering if using a compression code like this would actually make any significant improvement on the amount of data I can store in local storage? (or a key for that matter)
|
|
inherit
201984
0
Sept 11, 2023 1:23:07 GMT -8
P̌̓aͧś̀t̀u͒le͆o͂2̀3̃̓
Using My Talents Elsewhere
3,314
November 2013
pastuleo23
|
Post by P̌̓aͧś̀t̀u͒le͆o͂2̀3̃̓ on Sept 1, 2015 20:24:24 GMT -8
I'm debating a substantial re-write to my {username} to @ username plugin. I'm just wondering if using a compression code like this would actually make any significant improvement on the amount of data I can store in local storage? (or a key for that matter) That is actually a nifty find: var string = "This is my compression test.";
alert("Size of sample is: " + string.length);
var compressed = LZString.compressToUTF16(string);
alert("Size of compressed sample is: " + compressed.length);
localStorage.setItem("myData",compressed);
string = LZString.decompressFromUTF16(localStorage.getItem("myData"));
alert("Sample is: " + string); That example says it all. I ran some examples a couple words actually become larger in data size, and paragraphs tend to shrink size by 40%. In theory its cool. I don't think that much text should ever be saved. But compressing ToUTF16 (which is required for local storage -and probably keys-) is a lot of work. Were talking about 1/10 of a second
|
|
inherit
216224
0
Aug 1, 2024 1:18:46 GMT -8
Quozzo
408
November 2014
quozzo
|
Post by Quozzo on Sept 2, 2015 23:04:21 GMT -8
Using more storage space than usual for local/session storage should prompt the user if it is permitted. For a lot more you should look into WebSQL although I've not used it myself, never needed that much client side storage.
|
|
inherit
173855
0
Apr 23, 2024 9:59:44 GMT -8
Texas
I check in every once in a while...
869
November 2011
petermaggio
|
Post by Texas on Sept 4, 2015 8:00:27 GMT -8
Well, the purpose of the local storage is to cache usernames and display names. I don't want to use a user key because it just feels like a waste, but there are a lot of users on many forums (like this one). So naturally I'd like to be able to save as many as possible.So I'd only be converting small strings (2-15 on average). Basically meaning it probably won't actually save much unless I convert the entire object to a string and then compress it...which actually honestly might make more sense then compressing each individual username.
Edit: I ran a few tests and it seems like just using the normal compression method (meaning not to UTF8) seems to work fine for saving with local storage. Additionally, the string went from 11654 to 1885 which is pretty good. (16% of the original size). There was a bit of lag as far as the code processing time goes, but the browser itself didn't lag or anything.
|
|
inherit
201984
0
Sept 11, 2023 1:23:07 GMT -8
P̌̓aͧś̀t̀u͒le͆o͂2̀3̃̓
Using My Talents Elsewhere
3,314
November 2013
pastuleo23
|
Post by P̌̓aͧś̀t̀u͒le͆o͂2̀3̃̓ on Sept 4, 2015 18:16:05 GMT -8
Well, the purpose of the local storage is to cache usernames and display names. I don't want to use a user key because it just feels like a waste, but there are a lot of users on many forums (like this one). So naturally I'd like to be able to save as many as possible.So I'd only be converting small strings (2-15 on average). Basically meaning it probably won't actually save much unless I convert the entire object to a string and then compress it...which actually honestly might make more sense then compressing each individual username. Edit: I ran a few tests and it seems like just using the normal compression method (meaning not to UTF8) seems to work fine for saving with local storage. Additionally, the string went from 11654 to 1885 which is pretty good. (16% of the original size). There was a bit of lag as far as the code processing time goes, but the browser itself didn't lag or anything. Interesting. But yeah it does take some time for that conversion. So if u unthread it with a settimeout command in the header it should keep from pausing your other codes and start uncompressing as soon as possible
|
|