--- fulljsmin-orig.js 2009-11-05 13:36:42.283842300 -0600 +++ fulljsmin.js 2009-11-05 13:39:22.482842300 -0600 @@ -1,4 +1,11 @@ -/* jsmin.js - 2006-08-31 +/* jsmin.js - 2009-11-05 +Author: Billy Hoffman +This is a patched version of jsmin.js created by Franck Marcia which +supports important comments denoted with /*! ... +Permission is hereby granted to use the Javascript version under the same +conditions as the jsmin.js on which it is based. + +jsmin.js - 2006-08-31 Author: Franck Marcia This work is an adaptation of jsminc.c published by Douglas Crockford. Permission is hereby granted to use the Javascript version under the same @@ -132,17 +139,41 @@ } break; case '*': + //this is a comment. What kind? get(); - for (;;) { - switch (get()) { - case '*': - if (peek() == '/') { - get(); - return ' '; + if(peek() == '!') { + //important comment + var d = '/*!'; + for (;;) { + c = get(); + switch (c) { + case '*': + if (peek() == '/') { + get(); + return d+'*/'; + } + break; + case EOF: + throw 'Error: Unterminated comment.'; + default: + //modern JS engines handle string concats much better than the + //array+push+join hack. + d+=c; + } + } + } else { + //unimportant comment + for (;;) { + switch (get()) { + case '*': + if (peek() == '/') { + get(); + return ' '; + } + break; + case EOF: + throw 'Error: Unterminated comment.'; } - break; - case EOF: - throw 'Error: Unterminated comment.'; } } break;