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
Peter Bowey Computer Solutions
However, apart from this essential missing support event (in JSMin.PHP) you have a some great ideas! Thank you for sharing the project. It benefits us all. Thank you
Peter Bowey
peipians admin
Thanks :)
bug in jsmin
hello,
I’like to thank you first for the jsmin, library,
I have a bug with inline comments, this is my script
//AC_AX_RunContent( ‘width’,‘250 ’,‘height’,& #8216;260’,‘src 217;,‘http://www.youtube .com/v/XxIRHcFYOGs&hl=fr&a mp;fs=1&’,‘typ e’,‘application/x- shockwave-flash’,‘ allowscriptaccess’,̵ 6;always’,‘allowfu llscreen’,‘true 217;,‘movie’,̵ 6;http://www.youtube.com/v/XxI RHcFYOGs&hl=fr&fs=1&am p;’ ); //end AC code
after minifiyng the code remains and only // are removed, so that I need to strip inline comments before minifying files.
I hope you’ll fix this soon,
thanks again
- Thierry Bela
re: bug in jsmin
sorry,
I double checked my code, the problem is from me.
thank you.
- Thierry Bela
Awesome - using it in a script of my own
Hey, this is really nice. I just wrote a PHP class that will automatically combine external JS into a single file, then uses your script to minify it.
Post at http://any.onecancode.com/?p=1 8, code at http://github.com/anyonecancod e/jsFold/blob/master/classes/c lass.jsfold.php
It’s my first time using github, or posting code publicly for that matter, so I hope I followed all the appropriate conventions for giving credit, etc. Anyhow, thanks for the script, very handy!