3 ms·
I think a more 'popular' pattern is is to base64 encode the JSON. This is how we do it (tracking pixels/get requests), and lots of analytics/ad tech uses that p
by dillondoyle 7y ago
I think a more 'popular' pattern is is to base64 encode the JSON. This is how we do it (tracking pixels/get requests), and lots of analytics/ad tech uses that pattern as well. But I'm not sure on the compression/size.
- KilledByAPixel 7y agoEncoding to base64 increases the size by at least 33%. This is to help make links small enough to share on places like twitter, dischord etc where the max length is around 4000 bytes.
- stock_toaster 7y agoIf you compress the json first, it isn't quite so bad. Example #1 (short string): input: 103 bytes gzip(input): 87 bytes base64(gzip(input)): 117 bytes Example #2 (long string): input: 3122 bytes gzip(input): 840 bytes base64(gzip(input)): 1121 bytes
- KilledByAPixel 7y agoThanks, that is good reference. It makes sense that Zip would beat out JSON for longer strings. Just as another point of comparison, how about encodeURIComponent(gzip(input))?
- zaarn 7y agoThis project also blows up the size and it seems by much more than 33% on average. You'd safe some space by using base64.