422,363 Members | 2,303 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 422,363 IT Pros & Developers. It's quick & easy.

Client Side Data Compression (JavaScript)

P: n/a
Need to transfer large data (Appox 5MB in the form of XML & HTML) from
Internet Explorer to Web sphere application server. Want to know if
there is anyway I can compress data (JavaScript or otherwise) before
sending it to the server as it takes a long time to do this operation.

I am currently using xmlhttp. Sample code below.
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
xmlhttp.open("POST",'http://xyz.com',true);
var vSendXML = vMainXMLDOM.xml;//The size of vSendXML is appox 5 MB
xmlhttp.send(vSendXML);

Note: From the server to client I am using GZIP for compression and it
is working pretty good.

Feb 2 '06 #1
Share this Question
Share on Google+
8 Replies


P: n/a

vn*******@gmail.com wrote:
Need to transfer large data (Appox 5MB in the form of XML & HTML) from
Internet Explorer to Web sphere application server. Want to know if
there is anyway I can compress data (JavaScript or otherwise) before
sending it to the server as it takes a long time to do this operation.

I am currently using xmlhttp. Sample code below.
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
xmlhttp.open("POST",'http://xyz.com',true);
var vSendXML = vMainXMLDOM.xml;//The size of vSendXML is appox 5 MB
xmlhttp.send(vSendXML);

Note: From the server to client I am using GZIP for compression and it
is working pretty good.


If it is only you who sends data to the server, and not someone else
who is viewing one of your pages, you likely have a few options. Since
I am on broadband, I would not find sending a 5MB uncompressed file to
the server any problem, unless I had to do it dozens of times a day, so
broadband likely is the most simple option, although it might be
difficult to justify the cost if this is the only reason broadband
might be useful to you.

There are many programs available to compress data on your computer,
and some, such as Windows XP have an ordinary .zip program built in.
You can zip just about any combination of files, directories, images,
music etc. At my server, I can go to the control panel and unzip any
files that I have sent it such as zip, gzip, tar, etc. However it
sounds as if you might want the unzip function to be done automatically
at the server so the files can be used for something there. If so, this
likely would require a bit of server side code, perhaps php.

Feb 2 '06 #2

P: n/a

vn*******@gmail.com wrote:
Need to transfer large data (Appox 5MB in the form of XML & HTML) from
Internet Explorer to Web sphere application server. Want to know if
there is anyway I can compress data (JavaScript or otherwise) before
sending it to the server as it takes a long time to do this operation.

I am currently using xmlhttp. Sample code below.
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
xmlhttp.open("POST",'http://xyz.com',true);
var vSendXML = vMainXMLDOM.xml;//The size of vSendXML is appox 5 MB
xmlhttp.send(vSendXML);

Note: From the server to client I am using GZIP for compression and it
is working pretty good.


I am only an amateur at this, and the following is a bit of a guess:-

OPTION 1

1. Use a zip ActiveXObject to compress the file.

2. Set the dataType for a blank XML node to "bin.base64" and insert
the binary of the zip using nodeTypedValue.

You will lose some of the benefits of zip compression through base 64
encoding.

OPTION 2

If you can get the binary into Javascript somehow (perhaps using
ADODB.Stream if not disabled), I think you can also send pure binary as
an argument to the send method:-

<URL:http://www.devguru.com/Technologies/xmldom/quickref/httpRequest_send.html>

Extract: "This method takes one parameter: the requestBody to use.
Acceptable input types are BSTR, SAFEARRAY of UI1 (unsigned bytes),
IDispatch to an XMLDOM object, and IStream."

Regards

Julian

Feb 2 '06 #3

P: n/a
vn*******@gmail.com wrote:
Need to transfer large data (Appox 5MB in the form of XML & HTML) from
Internet Explorer to Web sphere application server. Want to know if
there is anyway I can compress data (JavaScript or otherwise) before
sending it to the server as it takes a long time to do this operation.

I am currently using xmlhttp. [...]
Note: From the server to client I am using GZIP for compression and it
is working pretty good.


Why, you can use a gzip implementation in JS/ECMAScript and compress the
data before you send it. The question is only whether this is fast enough.
PointedEars
Feb 2 '06 #4

P: n/a
1. Compression works by identifing repetition, indexing it and
referencing it so only the most atomic identifiers are repeated.
2. XML is full of repetition.
3. XML may also contain data that does nothing that you can strip.

No doubt somebody has already written something for this but personally
I'd:
1. Write a function that striped all the unecessary whitespace from the
XML with the exception of <!CDATA[ ]]> areas
2. Write a function that stores each unique tagname in an array.
3. Write a function that stores each unique attribute in an array.
4. Write a function that stores each unique tag content in an array.
(Keep the arrays separate)
5. Subtitute each tagname, attribute and tag content for the relevent
array index (greatly reducing the size of the XML) You could use just
letters as the array indices if you want to keep the XML valid.
6. Send over the contents of all the arrays, which arrays are which,
and the XML.
7. Use server side code to decompress by replacing the indices with
values stored in the arrays.

Feb 2 '06 #5

P: n/a
Thanks Julian Turner, Due have any code samples for either Option 1 or
2 or some related web site that you can suggest.

Feb 2 '06 #6

P: n/a
Thanks Thomas,
"Why, you can use a gzip implementation in JS/ECMAScript and compress
the
data before you send it. The question is only whether this is fast
enough. "

Can you please help me with more information on "JS/ECMAScript"

Feb 2 '06 #7

P: n/a
svaaps wrote:
Thanks Thomas,
"Why, you can use a gzip implementation in JS/ECMAScript and compress
the data before you send it. The question is only whether this is fast
enough. "

Can you please help me with more information on "JS/ECMAScript"


This is an abbreviation for the languages discussed in this newsgroup:
ECMAScript implementations like (Netscape) JavaScript and (Microsoft)
JScript.

Please learn to post, NetNews has threads to indicate the process of
discussion. Please learn to quote, USENET knows a sequence of leading
quote characters to indicate quotation level, and an attribution line
to indicate the author of the quoted material.

<URL:http://jibbering.com/faq/faq_notes/pots1.html#ps1Post>
<URL:http://www.safalra.com/special/googlegroupsreply/>
PointedEars
Feb 2 '06 #8

P: n/a

svaaps wrote:
Thanks Julian Turner, Due have any code samples for either Option 1 or
2 or some related web site that you can suggest.


Sorry, don't have any particular code working on this, and can't really
suggest any specific web sites.

I suggest you google on combinations of terms such as "dataType"
"bin.base64" "ADODB.Stream" and "zip ActiveX controls" and see what
comes up.

Regards

Julian

Feb 3 '06 #9

This discussion thread is closed

Replies have been disabled for this discussion.