Client Side Data Compression (JavaScript)

V

vnarayana

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.
 
C

cwdjrxyz

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.
 
J

Julian Turner

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
 
T

Thomas 'PointedEars' Lahn

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
 
O

oliver.saunders

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.
 
S

svaaps

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

svaaps

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"
 
T

Thomas 'PointedEars' Lahn

svaaps said:
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
 
J

Julian Turner

svaaps said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,073
Latest member
DarinCeden

Latest Threads

Top