On 9/21/2009 8:31 AM, Lars Huttar wrote: > Didn't see this message until just now... > > On 9/15/2009 2:46 PM, Jeroen Reijn wrote: > >> I wrote a small reader, which uses JSMin for minification of >> javascript files. I've written a blogpost[1] about this reader or you >> can get the source directly from [2]. >> >> Since I did not find a proper place for this reader just yet, I've put >> it online so you can download it. >> >> Cheers, >> >> Jeroen >> >> [1]http://blog.jeroenreijn.com/2009/09/apache-cocoon-and-javascript.html >> [2]http://people.apache.org/~jreijn/sources/java/JavaScriptMinifyReader.java >> Jeroen,
Thanks for posting this. I'm working on installing JavaScriptMinifyReader in Cocoon 2.1.11 and will probably have questions on how to get it to work! Meanwhile, I looked a little more at JSMin itself... I was surprised to learn that it's not very "safe." E.g. it "strips Microsoft’s conditional compilation comments" [1] and can produce incorrect results for certain expressions[2] even though it claims that it "does not change the behavior of the program that it is minifying." Granted, we can probably avoid the latter problems by going over our javascript with JSLint, which we should probably do anyway... but the whole thing does not really inspire confidence. On the other hand, [4] says JSMin is "considered safe", and Arthur Blake sounds like he knows a thing or two. Despite the above hesitation, I'll be glad to have on-the-fly minification available using JSMin and JavaScriptMinifyReader. I just wonder if there's a way to get around the problem of different versions of Rhino potentially clashing, so that one could take advantage of YUI Compressor. Also, I see JSMin does not "obfuscate", which I understand to mean replacing identifiers (variable names, etc.) with shortened versions. Maybe that's why JSMin didn't achieve as much compression as YUI Compressor or Shrinksafe[3] when I ran Compressorator on a sample. However, with gzip added, the difference between JSMin and YUI Compressor is negligible, less than 1%. In fact, JSMin achieves *better* compression than ShrinkSafe, when the results are gzipped. So I think the lack of "obfuscation" in JSMin is not a significant drawback. Lars [1]http://www.inconspicuous.org/2007/08/21/update-to-jsminjava/#comments [2]http://www.crockford.com/javascript/jsmin.html - see under "Caution" [3]YUI Compressor: 36.1%; ShrinkSafe: 39.5%; JSMin: 40.6% - all before gzipping [4]http://compressorrater.thruhere.net/ --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@cocoon.apache.org For additional commands, e-mail: users-h...@cocoon.apache.org