Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compressing json posted with jquery

Tags:

json

jquery

gzip

I'm posting a json string to my server however I'm wondering if there is a way to post this string compressed with gzip? the content-length is 24kb which is the same size as if I pick the posted JSON and paste it on a textfile so it obviously is not being compressed.

like image 787
ryudice Avatar asked Jun 12 '11 20:06

ryudice


1 Answers

You could use some JS library to compress the data, for example this Huffman compression implementation. However the added slowness of the compression might very well offset the time you save in upload speed. You have to try it and make that decision for yourself, but in general this sounds like it's not worth it. Especially since it means loading more JS code, which creates slower page load time.

Unfortunately the browsers do not provide APIs to any compression algorithms. So you can't use a fast built-in implementation.

like image 145
Seldaek Avatar answered Nov 20 '22 04:11

Seldaek