- A great JavaScript compressor In WebTech, 449 days ago
-
When you use a large JavaScript library and you’re done hacking and tuning it (yes, it occurs everytime), what you need is a powerful JavaScript compressor that will reduce the codesize (and pimps up your “page speed”). Prototype is difficult to compress, and the notorius Dean Edwards packer will not work because of all those missed semicolons.. pfff…
After an unsuccesfully try to compile jscompact, I did finally found the solution: bananascript ONLINE compressor. It compresses by about a stunning 70% (it actually really compress the code, not only packs it). The only two downsides are:
- you have to trust that guy… you give the guy the code, he will compress it and then, once compressed, the code is completely unreadable: what about some little nifty trojan? (sorry, man)
- you need to explicitely set the charset of your compressed JavaScript file(s) to ISO-8859-1
Here is how:
<script type="text/javascript" charset="ISO-8859-1" src="/misc/prototype.pack.js"></script> <script type="text/javascript" charset="ISO-8859-1" src="/misc/effects.pack.js"></script>
A quite “standard” prototype.js plus an effects.js went from an uncompressed 92KB to a compressed 26KB…
(Note that, however, you could gzip them without packing and you get a 21KB .gz; only need to set your httpd to serve gz’ed files)
Live and prosper!
Update it seems that the packer does not play nice with Safari :( (at least with prototype)
- michele said:
You mught want to try Dojo ShrinkSafe: http://alex.dojotoolkit.org/shrinksafe/
Posted on 06/03/07 11:28 AM #
- wildcard said:
I just decompressed Prototype1.5.1 in IE7, FF2, NN8, Safari 3, Opera 9 on PC and FF and Safari on Mac and compared the output which was identical and working in all browsers.
I have never seen a charset being defined the way you do it and I don’t know if that is a standard way to do it. I recommend defining it like this (which is the standard way of doing it):
«meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-1”»
(replace « and » with correct characters)Posted on 06/14/07 02:51 PM #
- claudio said:
@wildcard: yes, it’s a “standard way”. You can read about it http://www.w3.org/TR/html401/interact/scripts.html#h-18.2.1
What you reccomend is not really what I need, because I want to use UTF8 all over my document (but NOT in the script, that is part of).
Thanks for your comment.Posted on 06/16/07 08:29 PM #
- wildcard said:
Yeah, I read up about it and of course you’re right.
Did you try compressing again with the latest version?
If there is something wrong I would like to know what so I can fix it. I couldn’t find any problems with prototype 1.5.1 in any browser on either mac or pc. I have done some changes the past weeks and maybe you didn’t compress with the latest version?Posted on 06/17/07 12:50 AM #
Comments
commenting closed for this article
→ 61648624
→

