Update to JSMin.java
21 August 2007For anyone using JSMin.java, I’ve made a small update to JSMin.java to match with the latest jsmin.c. Thanks to Manuel Dominguez Sarmiento for pointing out the mismatch between the two.
For anyone using JSMin.java, I’ve made a small update to JSMin.java to match with the latest jsmin.c. Thanks to Manuel Dominguez Sarmiento for pointing out the mismatch between the two.
9 Responses to “Update to JSMin.java”
August 30th, 2007 at 9:43 pm
Can you list the changes done recently .. or is there any other location where I can see the changelog?
August 30th, 2007 at 9:54 pm
Of course. There is a diff at http://www.inconspicuous.org/projects/jsmin/jsmin20070820.patch
August 30th, 2007 at 11:57 pm
Thanks John.
February 12th, 2009 at 3:19 pm
One problem I’ve encountered with JSmin is that it strips Microsoft’s conditional compilation comments. I found a JavaScript version of JSmin that’s been modified to leave conditionial comments alone:
http://tanny.ica.com/ICA/TKO/tkoblog.nsf/dx/jsmin-and-javascript-conditional-comments
I tried porting the change over to your library, but I don’t know much about Java and couldn’t seem to get it to work. My code is available at the link below, with the changed lines highlighted. (The meat of the fix is around line 143.)
http://pastebin.com/f4286507e
Could you please take a look at this and see if you can get it to work? I’d really appreciate it. Thanks!
September 30th, 2009 at 2:48 pm
Gentlemen,
I was working on a client who had a version of your JSMin.java. For me it was not minifying CSS in away that allowed background-position to work with - numbers. Below are the modifications I made (in case anyone is still working on this project).
The JSMin had the following header (the client has an old tech stack, java 1.3, so this is really the only minifier that works, YUI Compressor won’t cut it).
/*
*
* JSMin.java 2006-02-13
*
* Updated 2007-08-20 with updates from jsmin.c (2007-05-22)
*
* Copyright (c) 2006 John Reilly (www.inconspicuous.org)
*
I went ahead and modified a line to allow for the background-position css property to contain negative numbers. Initially the JSMin would do this:
background-position:-134px-43px;
Which causes a CSS error. I added a line preceding line 218, and it looks like the below. You will notice I added a comment and an if(theB == ‘-’) action(1);
public void jsmin() throws IOException, UnterminatedRegExpLiteralException, UnterminatedCommentException, UnterminatedStringLiteralException{
theA = ‘\n’;
action(3);
while (theA != EOF) {
switch (theA) {
case ‘ ‘:
//this allows for the background-position negative(-) px values to work
if(theB == ‘-’) {
action(1);
} else if (isAlphanum(theB)) {
action(1);
} else {
action(2);
}
break;
case ‘\n’:
December 9th, 2009 at 4:28 am
Can someone please help me how to use this jar in ant build script.
June 27th, 2010 at 3:06 am
@Dave - It’s not meant to minify css - it only works on javascript.
June 27th, 2010 at 3:10 am
@Hemakumar - I have not published a jar file - just add the java file to your project and modify it as needed. Personally I would recommend against using JSMin - I no longer use it, instead opting for the yui compressor. See http://developer.yahoo.com/yui/compressor/
June 27th, 2010 at 3:11 am
Apologies for the late replies - I only saw the comments in the approval queue now - I don’t remember getting any emails about them