JSMin+ version 1.2

By crisp on Saturday 18 April 2009 01:12 - Comments (19)
Category: JSMin+, Views: 7.247

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:
  • 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
Known issues:
  • JScript conditional compilation support is not complete yet
The latest version is available on http://files.tweakers.net/jsminplus/jsminplus.zip

You can read more about JSMin+ in the announcement post.

Volgende: JSMin+ version 1.3 05-'09 JSMin+ version 1.3
Volgende: JSMin+ version 1.1 04-'09 JSMin+ version 1.1

Comments


By Tweakers user --MeAngry--, Saturday 18 April 2009 11:19

Yay! _/-\o_ I'll be sure to test this new version starting next week. Thanks for all the efforts you're putting into this. :)

By Tom Keim, Saturday 18 April 2009 14:44

Thanks for this tool! _/-\o_ My website's javascript files are a lot smaller!

By Tweakers user BasieP, Monday 20 April 2009 10:50

Great,
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

By Tweakers user Lennie, Friday 24 April 2009 13:54

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. :-)

[Comment edited on Friday 24 April 2009 13:59]


By Tweakers user 4VAlien, Friday 24 April 2009 16:03

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?

By Tweakers user crisp, Saturday 25 April 2009 14:16

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.

By Tweakers user BasieP, Monday 27 April 2009 14:05

and global var names can't be minified either ofcourse.

By Tweakers user Blaise, Friday 8 May 2009 15:49

I'm getting an error when including jquery 1.3.2, minified with version 1.2: "event.isPropagationStopped is not a function"

By Tweakers user Xanland, Friday 8 May 2009 21:44

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. :P

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. ;)

By Tweakers user crisp, Friday 8 May 2009 23:56

Xanland: no, it's not a CSS minifier

By Tweakers user crisp, Saturday 9 May 2009 01:34

Blaise: it seems Narcissus doesn't handle cases like this well:

JavaScript:
1
var a = foo ? bar ? 1 : 2 : 3;


I'm trying to figure it out...

By Tweakers user Xanland, Saturday 9 May 2009 18:25

Meh, too bad.

You say btw in the first post about JSMin+ this:
For 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.
Anywayz, I go to search a CSS minifier :+.

By Tweakers user crisp, Saturday 9 May 2009 19:19

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.

By Tweakers user crisp, Sunday 10 May 2009 01:49

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+

By Tweakers user crisp, Tuesday 12 May 2009 01:24

I made a new issue for this with a proposed patch: https://bugzilla.mozilla.org/show_bug.cgi?id=492445

By Tweakers user Spider.007, Friday 15 May 2009 11:19

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

By Tweakers user crisp, Friday 15 May 2009 11:30

Current development version has some fixes for empty bodies in if/else or loop-constructs, so wait up for version 1.3 :)

By Tweakers user Spider.007, Friday 15 May 2009 11:45

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)

[Comment edited on Friday 15 May 2009 11:47]


By Tweakers user crisp, Friday 15 May 2009 11:51

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