Monday, April 2nd, 2007
Packer 3.0 and isMSIE hacks
Dean Edwards has released Packer v3.0, one of the top utilities to squeeze your JavaScript like a lemon.
- respects Microsoft conditional comments
- new option to shrink variable and argument identifiers
- removed the special chars feature
(except the;;;feature which people seem to like)- some bug fixes:
- packer no longer closes spaces between the
+/-operators so code like this is safe:c = a++ +b;- the
throw"error"}bug that affected Safari (this is a Safari bug really but packer gets around it)- the
__proto__bug for Mozilla browsers (this only affected the online version of packer)- a minor parsing bug affecting the detection of regular expressions
- simplified the user interface
Dean also had some fun sniffing browsers and came up with the short test:
-
-
var isMSIE = /*@cc_on!@*/false;
-
but then Sil came up with:
-
-
var isMSIE//@cc_on=1
-












awesome, have always used dean’s packer for my projects.
Can someone explain why you’d ever want to compress you JS yourself instead of just using mod_deflate or your web server’s equivalent module? With hardware being so cheap, and compression not being very expensive, why not let the web server deal with it so you can deploy plain, formatted js (and css, and html, etc)?
Rob, I feel you are entirely missing the point.
Compression plays a huge role in modern computing, the fact that the server has to perform the work every time the script is being loaded can be very redundant.
Also, this plays a role in saving bandwidth alongside processing, which can be key for all webmasters. One file being loaded and processed hundreds of times in a minute can be a noticeable difference.
Shawn: yes the web server will compress on every request, but I trust Apache or lighty have optimizations in there to handle common files (like your standard JS files).
If enabling mod_deflate really makes or breaks your server, you have much bigger issues then compressing your content.
There are many situations where users don’t have access to mod_deflate or similar, so a packer like this is really useful.