I wasn't happy with the performance of the existing PHP port of JSMin, so I wrote my own implementation, which is significantly smaller and faster. This new library will be included in the next release of Minify, and you're welcome to download it and use it in your own projects:
require 'jsmin.php';
// Output a minified version of example.js.
echo JSMin::minify(file_get_contents('example.js'));
Comments
No title
Oh neat, I started checking out minify when I saw your post on wednesday but haven't put it into use yet. Thanks on bringing awareness to that while making it work better.
Thanks
Unfortunately I'm on PHP 5.2.0 (0.0.1 versions away, *cries*) so when I used minify the response I got from the server was...
"Call to undefined function sys_get_temp_dir()"
This function seems to be supported as of PHP 5.2.1...reading the manual comment for this page suggested that it is possible to create this function...
Check here for details...http://us2.php.net/sys_get_temp_dir
Prob not best workaround to add this to the start of the minify file but just for experiementing with it before I upgrade seems to work ok.
Strict Error
Strict Standards: Redefining already defined constructor for class JSMin in jsmin-1.0.1.php on line 167
Re: Strict Error
I've released version 1.1.0, which fixes the error. Thanks.
No title
What about IE conditional comments ?
/*@cc_on
if ( @_jscript_version == 5.6 )
document.execCommand("BackgroundImageCache", false, true);
@*/
No title
At the moment, conditional comments are clobbered. That's because this is a direct port of Doug Crockford's jsmin.c, which does the same thing.
I don't intend to change the default behavior to be different from jsmin.c, but I'll consider adding an option not to remove conditional comments.
Thanks and question
Hello,
Thanks for the port into PHP5 and its simple usage. I looked at the source but don't think there is an option switch to further remove the newlines