And Peter Piper picked a peck of pickled peppers.
Another port of packer. This time a PHP version by Nicolas Martin:
http://joliclic.free.fr/php/javascript-packer/en/
So far a version of packer exists in the following languages:
- My original JavaScript version
- A version in perl by Rob Seiler
- A version in python (not sure this works)
- A .NET conversion by Jesse Hansen
- This new PHP version
- Dan Webb works on a conversion to ruby
- And I’m working on version 3.0 which is written using Base. This version includes the facility to shorten variable and argument names for true obfuscation and better compression.
The download page contains links to all of the above versions.
There is also this web service thing to try. And this Rhino port might be interesting to some.
Comment: #1.
Good stuff. Just FYI, in a pinch, Troels Jakobsen’s Bookmarklet Builder does a bang-up job of “unpacking” minimized JS pretty well, though it’s not as reliable for minimization.
Comment: #2.
Looking forward to v3.0. Many people pass js files through custom_rhino before using packer. rhino makes JavaScript code more well formed and ensures that the packed code works. rhino already shortens variable and argument names. Maybe the new version of packer can take advantages of custom_rhino.
Comment: #3.
What a coincidence! I just did a same port of the packer in PHP a few weeks ago.
Comment: #4.
prototype.js don’t work after be packed.
Someone find a way to pack it ?
Comment: #5.
Nao, you have to ensure semi-colons are present in a lot of areas. I usually visually scan it look for areas to add them, then use Firebug to debug and figure out where the ones I missed are.
Comment: #6.
no port, but apatana integration of packer: http://pfirsichmelba.de/d.edwards_packer2aptana.zip
Comment: #7.
@alerxander - thanks for the aptana plugin! I’ve added it to the download page.
Comment: #8.
Nao, here is another javascript compressor. It compresses several kB better and seems to compress prototype.js ok without any changes made to it. No javascript errors popup after it is compressed. http://www.fanskap.se/crunch
Comment: #9.
The above compressor tool has been updated and moved to a new adress: http://www.bananascript.com/
Comment: #10.
Hi all-
I made a version of the above script for php4.
Comment: #11.
Comment: #12.
@Mark - Thanks for the PHP4 conversion. I’ll add it to the download page later.
Comment: #13.
Verry good job, I “had” lot of big js files. Thank you for this stuff !
Comment: #14.
Both PHP versions suffer from an old bug: if you have INSIDE a string something that starts with a $, that will be trimmed like if that were a variable.
Ex: var $var = “$this should not be changed!!”;
After compression: v = “t should not be changed!!”;
I think i reported this to Dean a long time ago, and the js version works as intended. I don´t know why the php version doesn´t, since i can see the regular expressions used to protect the strings…
Comment: #15.
We attempted to implement this PHP JS packer into a product we are building. While the packer works perfectly in our development systems, the second we pushed it into production it totally choked. Be advised that if you plan to use this in a high traffic environment, you would be wise to stress test it before exposing it to high volumes of on-the-fly packing.
Comment: #16.
Comment: #17.
Please give me some directions how to install Obfuscator in Aptana… Do I have to implement it as a Script?
Comment: #18.
Comment: #19.