News for hackers. Stuff that matters.
Re:Show HN: Compare different JS minifiers’ output online by worik on Sunday November 09, 2014 @03:57PM (#8580880)
"An error occurred while trying to compress javascript text."

Hmmm....

Firstly I think I gave it too much JS code to deal with and it choked (about 3,000 lines).

Running it twice in a row always causes it to fail in my experience so far.

I am not quite sure what it is trying to do. I get a little report like:

Original file size : 1,009bytes JSMin : 706bytes (30%) UglifyJS : 644bytes (36%) YUI Compressor : 647bytes (35%) Closure Compiler : 638bytes (36%)

but no sign of the compressed code except the code I enter has most new lines removed. The newlines between function declarations are maintained.

The above report I pasted inline is after I asked for one algorithm to be tested (Closure Compiler) but it reported on all of them.

This is a good idea, and it would be useful if:

(a) it could cope with 3,000 lines about 120K. That is not much

(b) Gave me a bit more information about what the compression is doing. I care about more than the sizw. At the very least show me the compressed code.

(c) Let me test one algorithm at a time

peace W

Re:Show HN: Compare different JS minifiers’ output online by gillyb on Sunday November 09, 2014 @04:05PM (#8580897)
Thanks for the comment. I will try to improve it within the upcoming days!
Re:Show HN: Compare different JS minifiers’ output online by Theyeard on Sunday November 09, 2014 @03:42PM (#8580833)
Wow, great idea. I wish this was available as a npm package.

A couple of things, sometimes the service doesn't work and returns "YUI Compressor : 0bytes (100%)" or "JSMin : 886bytes (0%)". A typo: succees.

The references section could be expanded with resources about writing JS code in a way that enables optimizations:

http://toddmotto.com/what-function-window-document-undefined...

https://curiosity-driven.org/minimal-loader

Re:Show HN: Compare different JS minifiers’ output online by gillyb on Sunday November 09, 2014 @03:45PM (#8580846)
Thanks for the feedback, I really appreciate it! I will do my best to fix this ASAP, and I was planning on adding more references anyways.
Re:Show HN: Compare different JS minifiers’ output online by dkopi on Sunday November 09, 2014 @03:48PM (#8580853)
Pretty cool, but comparing file sizes probably isn't enough. We should also compare the file sizes after gzipping. smaller js files doesn't necessarily mean smaller zipped files.

Also, size comparison ignores speed improvements due to load time and runtime optimizations that closure compiler does and uglify doesn't. (Although you'll have to use ugly code annotations to get closure compiler to do its magic).

Re:Show HN: Compare different JS minifiers’ output online by troels on Sunday November 09, 2014 @04:31PM (#8580975)
Also - On the negative side, de-compression may be costly on the client. That would be really interesting to see measured as well.
Re:Show HN: Compare different JS minifiers’ output online by gillyb on Sunday November 09, 2014 @03:51PM (#8580865)
Totally right! I'm thinking about adding an online gzip function to this as well, to see what the end result will be.
Re:Show HN: Compare different JS minifiers’ output online by slig on Sunday November 09, 2014 @03:43PM (#8580834)
Nice one, thanks for sharing!

I've been researching for a minifier recently and on my tests Closure Compiler always win on the file size metric. However, due to the Closure Compiler Java dependency, I'll likely choose UglifyJS (which is always the second best on my tests).

Have you noticed cases where Closure Compiler or UglifyJS aren't the best?

Re:Show HN: Compare different JS minifiers’ output online by gillyb on Sunday November 09, 2014 @03:48PM (#8580851)
From my personal testing UglifyJS and Closure Compiler are usually the best as well. They're also pretty close most of the time, but still I go with which ever one saves more.
Re:Show HN: Compare different JS minifiers’ output online by gillyb on Saturday November 15, 2014 @11:26AM (#8611977)
I fixed many of the bugs happening on the site, and there's much less traffic now, so if someone didn't get a chance to see it, you can come back now :)
Re:Show HN: Compare different JS minifiers’ output online by JayXon on Sunday November 09, 2014 @05:30PM (#8581128)
Very nice, could you display the best output result? So that we don't need to compress again ourselves.
Re:Show HN: Compare different JS minifiers’ output online by gillyb on Sunday November 09, 2014 @05:32PM (#8581135)
When uploading files, you can just download the one with the best compression. When inserting text, your text is replaces with the best compressed version. I understand I need to make that clearer. Thanks for the feedback, I will improve it!
Re:Show HN: Compare different JS minifiers’ output online by ilanco on Sunday November 09, 2014 @03:40PM (#8580827)
502 bad gateway
Re:Show HN: Compare different JS minifiers’ output online by gillyb on Sunday November 09, 2014 @03:42PM (#8580831)
REALLY sorry about that, it seems like I'm getting quite a lot of traffic from HN now. I'm trying to deal with it, and keep it up. Sorry for letting you down... :/
Re:Show HN: Compare different JS minifiers’ output online by LukeB_UK on Sunday November 09, 2014 @03:54PM (#8580872)
Sorry we broke your site!
Re:Show HN: Compare different JS minifiers’ output online by mmastrac on Sunday November 09, 2014 @03:16PM (#8580750)
This looks like it might have been an interesting submission, but I'm getting a bad gateway error when clicking through.

Also, you should re-title it as Show HN to get better visibility!

EDIT: author has fixed it.

Re:Show HN: Compare different JS minifiers’ output online by gillyb on Sunday November 09, 2014 @03:21PM (#8580764)
Thanks, I noticed that pretty fast, and got it back up. Hope it stays up for now...