views:

113

answers:

4

I have found the DIY Map.. an excellent map tool if you are ever looking for one. Aside from how fantastic it is... the associated XML file can get fairly large (it contains map setting, country names etc). I was wondering if it were possible to compress it and have javascript uncompress it on the users side....

There is a lot of repetition in there a lot of tags that I was thinking could be swapped with place holders and then replaced by the javascript...

or should I just rely on gzip to do that for me?

A: 

Store a pre-compressed file alongside the raw file so the compression doesn't have to happen at runtime. Implementing your own compression scheme will most likely not gain you anything (as long as you don't drop actual data) and will hurt client-side performance.

Christoph
+1  A: 

You could enable HTTP compression into your web server and let your browser to uncompress it.

You shouldn't do that in javascript;

Rubens Farias
I think Mark already does this - or how else would you interpret his last statement?
Christoph
+1  A: 

JS is very slow. GZIP is definitely the way to go.

jeffreyveon
A: 

GZip Compression is widely supported by web-servers and will give you a significant compression and therefore download speed.

Implementing your own scheme in JavaScript will be slow due to the extra string processing you will be doing on the client before you actually process your XML file.

This extra code will also be adding the possibility of additional bugs in your application if the search and replace matches things you do not expect. So would recommend you not add the extra engineering effort until you are certain it is required.

Tendayi Mawushe