473,386 Members | 1,752 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Client Side Data Compression (JavaScript)

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
8 11700

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

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

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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Don | last post by:
Does anyone know where I can find a client-side function I can reference from within an HTML/JavaScript web page? I'm currently using a core PHP function to do this, but I'd rather do it on the...
15
by: Michael Rybak | last post by:
hi, everyone. I'm writing a 2-players game that should support network mode. I'm now testing it on 1 PC since I don't have 2. I directly use sockets, and both client and server do...
18
by: cjl | last post by:
Hey all: I know that it is silly in the age of Google to 'lose' something on the internet, but I recently checked out a project that had implemented a database with a subset of SQL in pure...
5
by: KathyB | last post by:
If someone could just explain this to me...I just don't get it! I have an aspx page where I retrieve several session variables and use xmlDocument to transform xml file with xsl file into an...
6
by: Danny Tuppeny | last post by:
Hi all, I'm writing a news client (mainly to test out CAB & ClickOnce!), and trying to decide on what to use for the storage of messages etc.. SQL Express seems like overkill (and is a hefty...
14
by: Matt | last post by:
I want to know if ASP.NET Web Forms Validation Controls are Server-Side or Client-Side form validation? Since I think each validator control can select either 1) JavaScript based error dialog or 2)...
8
by: Mike Fellows | last post by:
Ok, im not sure if this is at all possible and if it is how i go about it is beyond me i have a piece of client side code that requires a piece of data from the server side (an ID number in this...
1
by: vidya | last post by:
Hi, I have a button which is a web control. I have some validation in javascript for the button in .aspx file and some in the button onclick event in code behind(C#). I need to get through both...
22
by: Dan Rumney | last post by:
Hi all, I've been writing Javascript for quite a while now and have, of late, been writing quite a lot of AJAX and AJAX-related code. In the main, my dynamically generated pages are created...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.