Compress/Decompress strings with javascript

Hi,

I keep really big amounts of data in .js files. Sometimes js files become 700-800 K or even more, which is a problem for slow connections.

Is there any way to compress the data stored in the .js file (let's say it's one huge string) and then decompress it through javascript on the visitor's machine?
What I need is the size to be reduced to max. 40% of the initial size, and the decompression to be relatively fast.

The compression might be slow and not in javascript, actually I would prefer VB(VBA) compression because the data will be generated from Excel.
hveldAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

NetGrooveCommented:
Is this link something for you:
http://www.websiteoptimization.com/speed/9/

By the way, I do not believe you will save significant time. The time you get in transfer you will loose in decompression with the option to have bad maintainable sources.
Better are the upper recommendation of source compaction with regular means.

Good luck,
NetGroove


0
_nn_Commented:
When it comes to text files (any form, HTML, js, css, whatever) of sizes of 100K or more, it should be handled at the protocol level. Well, for 700-800K, I'd still run a first "pass" with NetGroove's recommendation, e.g. some reasonable source code compaction would probably not hurt. Though, modern browsers accept compressed contents in gzip and/or deflate format. Both compression algorythms should be able to get very comfortable compression ratios on text files. And everything would stay transparent for the developer and the 'netsurfer'. It's just a matter of running and configuring a webserver that can compress on the fly. I still don't understand why the EE site itself doesn't use it... ah sorry, off-topic.
0
hveldAuthor Commented:
Thnx NetGroove but this link contains info/tools to optimize or compress scripts - mainly by removing everything that is not needed for the script to work.
What I need is to compress a string without removing anything from it - that is, a true compression. Later on when the string is  restored(decompressed) , it should be an exact copy of the input string.
0
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

NetGrooveCommented:
Sorry, but now I also think like _nn_ that you are wasting your time finding an easy method that YOU can do compression by script and decompression on browser side.
I do not know how this content compression by web server is done, but I know that most transmission hardware, like modems or network routers, already do the block content compression without any interference to upper layers.
Search for JavaScript compression in Google and you will see that you get Minutes! per kilobyte for compression and decompression with script methods. This is a task for hardware layers.

0
Michel PlungjanIT ExpertCommented:
PS: There is no zip for javascript if that is what you hoped
0
ZontarCommented:
Servers will send files with gzip compression automatically provided both they and the client understand it.
0
ZontarCommented:
BTW, if you're storing THAT much data in .js files, it's time to start looking into using a database.
0
Michel PlungjanIT ExpertCommented:
Yes - but I just wanted to make sure hveld did not expect some binary compression/decompression under his control
0
_nn_Commented:
FYI NetGroove, I don't know for other daemons, but for Apache :
- http://httpd.apache.org/docs-2.0/mod/mod_deflate.html
- http://sourceforge.net/projects/mod-gzip/
0
NetGrooveCommented:
Thanks _nn_
0
hveldAuthor Commented:
well what I need is possible, take a look at
htmlzip.com

This app compresses html files and reduces their size a lot, sometimes to 1/4 of the original size(for files larger than 30 K). Obviously this can't be done by simply removing the useless characters from the source.
I think it uses a javascript implementation of some compression algorithm - that's what I need. Unfortunately it can't compress script files and compressed html files sometimes don't work, but there is a way to compress text with javascript.

As for the other suggestions, I can't use them because of my host.
0
NetGrooveCommented:
Look at bottom of this page:
http://htmlzip.com/examples_z.htm

You will see two things: compression brings NOTHING (7105 bytes > 6026 bytes), but brings problems on browser side, like slow decompression.

If you want that algorithm for you, then you can pay for it, either to that company or to me. From me you will get the sources.

0
hveldAuthor Commented:
Well if you test it with a 100 K or bigger file there will be a difference. And I need to compress big files, like 700-800 K.
I would have bought the app but it can't compress script files, and compressed html files very often do not work. But I didn't notice a slow decompression. For big files, it's takes less time than the time needed to download the uncompressed file.
0
NetGrooveCommented:
So you are thinking about a way that I could make you an offer to implement that compression algorithm for javascript files, for money, right?
0
hveldAuthor Commented:
yes, please make an offer.
My email is <Email removed by GhostMod, CS Moderator>
0
jaysolomonCommented:
No comment has been added lately, so it's time to clean up this TA.
I will leave the following recommendation for this question in the Cleanup topic area:

PAQ - no points refunded

Please leave any comments here within the next four days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

jAy
EE Cleanup Volunteer
0
GhostModCommented:
PAQed - no points refunded (of 500)

GhostMod
Community Support Moderator
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.