2

Hi I'm making a word processor app.

Users will be able to edit the document (an xhtml doc) and save. This xhtml doc can become very big (a 50k word doc is 500kb), and posting the xhtml to a server can become slow.

I suppose the right way to do this is to send only the the diff data and patch in server. This can take time to develop and test.

To build the min viable product as fast as possible, I would like to compress the xhtml with javascript client-side, send the compressed file to the server and store it in the db compress.

Eventually I may need to get the xhtml back in ruby, for server processing, but not often.

Is there a way to compress an xhtml using javascript client-side?

Victor
  • 23,172
  • 30
  • 86
  • 125
  • 3
    [gzip in JavaScript](http://stackoverflow.com/questions/294297/javascript-implementation-of-gzip). Ask yourself, what's faster, gzipping 500k to 200k or sending an extra 300k to the server? – Raynos May 19 '11 at 21:15
  • 2
    You could implement something simple like http://en.wikipedia.org/wiki/Huffman_coding – cam May 19 '11 at 21:25
  • 3
    @Raynos: Good question. IMHO, in II/2011, gzipping would look favorable - processor speed is not really a concern, *upload* speed often is. – Piskvor left the building May 19 '11 at 22:25

1 Answers1

0

Several coders have written compression tools in JavaScript using Huffman coding:

http://rumkin.com/tools/compression/compress_huff.php

http://tom-ash.net/blogs/Programming/huffman_coding.html

http://www.ioyu.com/io/javascript/huffman.asp

Not aware of any way to do client-side compression natively from JavaScript.

Sam Dutton
  • 14,775
  • 6
  • 54
  • 64