JSMin+ version 1.2
Version 1.2 of JSMin+ is available for download. This version fixes PHP crashes in some versions (notably 5.2.9) on JS files with large comments or strings and handles if-else statements in a safer way. Overall the output size has been improved.
Changelog:
You can read more about JSMin+ in the announcement post.
Changelog:
- Fixed crash in PHP 5.2.9 when matching large comments or strings (due to PCRE backtracking bug)
- Don't add curly braces around statements for a CASE label
- Always put statements for IF between curly braces when followed by an ELSE
- Save some more bytes by omitting the space between RETURN and the return expression in certain cases
- JScript conditional compilation support is not complete yet
You can read more about JSMin+ in the announcement post.
05-'09 JSMin+ version 1.3
04-'09 JSMin+ version 1.1
Comments
Yay!
I'll be sure to test this new version starting next week. Thanks for all the efforts you're putting into this. 


Thanks for this tool!
My website's javascript files are a lot smaller!

Great,
In version 1.1 i had trouble with unfinished if-then-else statements
somthing like:
JavaScript:
trew parse/syntax errors (while it's not syntacticly incorrect)
i hope this version fixes that
In version 1.1 i had trouble with unfinished if-then-else statements
somthing like:
JavaScript:
1
2
3
| if (true) { //nothing here } |
trew parse/syntax errors (while it's not syntacticly incorrect)
i hope this version fixes that
Even without testing I noticed this in jsminplus.php:
18-04-2009 - fixed crashbug in PHP 3.2.9 and several other bugfixes
I presume you mean: 5.2.9 not 3.2.9. :-)
18-04-2009 - fixed crashbug in PHP 3.2.9 and several other bugfixes
I presume you mean: 5.2.9 not 3.2.9. :-)
[Comment edited on vrijdag 24 april 2009 13:59]
If you want to minify then should'nt identifiers be renamed? I would expect all variables and functions names to be renamed to something from [a-zzz]. Is this future work we can expect?
Yes. But it must be said that such minification can only safely be done for scoped variables, not for function names.Is this future work we can expect?
and global var names can't be minified either ofcourse.
I'm getting an error when including jquery 1.3.2, minified with version 1.2: "event.isPropagationStopped is not a function"
Nice script crisp, never used it until I started to developpng my own CMS.
The JS part works fine for me, but the CSS doesn't. But it is a JS and CSS minifier as you said, only you can never always fix all the bugs.
The error I get is this:
Parse error: Missing operand in file 'css/pro_dropdown_6_slimbox_style.css' on line 12
If you want to reproduce it you can find the file here: http://cms.xanland.nl/x/css/pro_dropdown_6_slimbox_style.css
Anywayz: Keep up the good work! Nice program.
The JS part works fine for me, but the CSS doesn't. But it is a JS and CSS minifier as you said, only you can never always fix all the bugs.

The error I get is this:
Parse error: Missing operand in file 'css/pro_dropdown_6_slimbox_style.css' on line 12
If you want to reproduce it you can find the file here: http://cms.xanland.nl/x/css/pro_dropdown_6_slimbox_style.css
Anywayz: Keep up the good work! Nice program.

Xanland: no, it's not a CSS minifier
Blaise: it seems Narcissus doesn't handle cases like this well:
JavaScript:
I'm trying to figure it out...
JavaScript:
1
| var a = foo ? bar ? 1 : 2 : 3; |
I'm trying to figure it out...
Meh, too bad.
You say btw in the first post about JSMin+ this:
.
You say btw in the first post about JSMin+ this:
Anywayz, I go to search a CSS minifierFor some time we have been looking for ways to minify the javascript and CSS files for Tweakers.net but were unable to find the right tool for this.

Xanland: we just use a set of regular expressions to do CSS minification, it's not so hard and examples are plenty to find. However our CSS minification does some assumptions that make it unusable for general consumption.
Blaise: I tracked down the ternary issue and indeed this is a bug in Narcissus. Basically the nested ternary case resulted in an 'invalid label' error after bug 330975 was fixed, this issue was then resolved in bug 401405 but unfortunately this fix now proves incorrect (results in wrong tree-order because of precedence issues).
I proposed an amendment to that fix there which seems to work well in jsmin+, but I would like to await comments on that before rushing a new bugfix release of jsmin+
I proposed an amendment to that fix there which seems to work well in jsmin+, but I would like to await comments on that before rushing a new bugfix release of jsmin+
I made a new issue for this with a proposed patch: https://bugzilla.mozilla.org/show_bug.cgi?id=492445
Somehow, this version throws an " Uninitialized string offset: 0" notice, but I am unable to reduce the testcase any further then this:
http://home.react.nl/~sjo...tialized-string-offset.js
http://home.react.nl/~sjo...tialized-string-offset.js
Current development version has some fixes for empty bodies in if/else or loop-constructs, so wait up for version 1.3 

Thanks!
An additional tip for anyone looking to implement this minifier for large files (> 10k lines); I found out that splitting the file up, and putting these parts through the minifier is much faster then minifying the entire file at once.
A 12k lines JS file takes ~ 40 seconds to minify; but when minifying the 26 js files it consists of, merging takes ~ 20 seconds.
(the file went from 336 KiB > 256 KiB btw)
An additional tip for anyone looking to implement this minifier for large files (> 10k lines); I found out that splitting the file up, and putting these parts through the minifier is much faster then minifying the entire file at once.
A 12k lines JS file takes ~ 40 seconds to minify; but when minifying the 26 js files it consists of, merging takes ~ 20 seconds.
(the file went from 336 KiB > 256 KiB btw)
[Comment edited on vrijdag 15 mei 2009 11:47]
Spider.007: that's because PHP is much slower when having to do substrings on very large strings. There is probably more room for improvement there although I already partly adressed the issue by not taking a substring untill EOF for every token iteration.
Comments are closed