[Javascript] JavaScritpt simple compression code

Eligio Morgado eligio at gmail.com
Fri Feb 18 06:40:07 CST 2005


Hi Allard.

First of all, as you can see my English is not very good. I don't
understand very well your question.

My JavaScript code has many different files with many classes, arrays, etc.

I need to save this information in a DB because when you re-enter the
page you can load previous data.

So, I build a string concatenating all arrays data, class data, etc.

You are correct, that part of the code is quite slow, until geting the
full string.

Imagine:

var mytext = "";

for( var elem in array_a ) { mytext += "&" + elem + "=" + array_a[elem]; }
for( var elem in array_b ) { mytext += "&" + elem + "=" + array_b[elem]; }

And this continues for every data I need to persist.

Debuging the code, I see that forming the string it's a slow process
(as you say). But it's slowler when GETs started to be sent.




On Fri, 18 Feb 2005 10:23:43 -0200, Allard Schripsema
<allard-schripsema at procergs.rs.gov.br> wrote:
> Hi there
> 
> First of all i?d like to ask you if you are concatenating (using a loop) to
> get these big strings
> like for (...) {strchunk =getChunk() ; strtotal = strtotal + strchunk }
> 
> If this is the case, this probably is your big performance problem, NOT the
> sending of these strings. (even 50 querystrings = 100 tcp packets * 20 ms???
> NOT a "big" deal)
> The answer would be to avoid concatenating into the big string until the
> latest possible moment
> 
> If you?re after some simple compression tecnique, check out the .pcx
> (imageformat) compression.
> Or we could invent something here in this group, if you want.
> 
> great problem!
> 
> Allard Schripsema
> 
> 
> -----Original Message-----
> From: javascript-bounces at LaTech.edu
> [mailto:javascript-bounces at LaTech.edu]On Behalf Of Eligio Morgado
> Sent: Friday, February 18, 2005 10:09 AM
> To: [JavaScript List]
> Subject: Re: [Javascript] JavaScritpt simple compression code
> 
> Hi Matt.
> 
> Testing with IE, I found that I can send URLs of less than 2000
> characters. So I split original string in 1900 length parts (I don't
> like to reach the exact limit).
> 
> The largest string I have found is about 200.000 characters.
> Fornutatly, normally they are about 1000-5000 (sometimes I only GET
> one time).
> 
> Don't mind for strings larger than 200.000. This is a very specific
> scenary and I can create a rule for not sending strings larger than
> 250.000, for example.
> 
> In response to POST vs GET, I found that with default IE configuration
> user gets a security message when trying to submit the hidden form.
> That's why I disagree with POST.
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> https://lists.LaTech.edu/mailman/listinfo/javascript
> 
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> https://lists.LaTech.edu/mailman/listinfo/javascript
>



More information about the Javascript mailing list