PDA

View Full Version : new the-yui-compressor for js



nassaja-rus
14 Aug 2007, 10:16 PM
http://www.julienlecomte.net/blog/2007/08/13/introducing-the-yui-compressor/

Who already tried?

matjaz
15 Aug 2007, 2:47 AM
It shrinks ext-all additionally by 20kB so it's no a big deal.

I'm using Dean Edwards packer and it's great.
This one promises us same quality without issues with eval and with statements.
So generally it's a promising tool !

jay@moduscreate.com
15 Aug 2007, 8:05 AM
20Kb is pretty damn huge.

J.C. Bize
16 Aug 2007, 10:03 AM
good deal, thanks for the heads up!

Animal
20 Aug 2007, 1:34 AM
I just changed our ant build to use the yui-compressor rather than Dojo's version. It's smaller, and Dojo's version seems dojoishly flaky - it sometimes blows up

jay@moduscreate.com
20 Aug 2007, 7:21 AM
I just changed our ant build to use the yui-compressor rather than Dojo's version. It's smaller, and Dojo's version seems dojoishly flaky - it sometimes blows up



Interesting term: dojoishly :)

http://i157.photobucket.com/albums/t76/guinnea1/44.gif

trbs
20 Aug 2007, 8:10 AM
I just changed our ant build to use the yui-compressor rather than Dojo's version. It's smaller, and Dojo's version seems dojoishly flaky - it sometimes blows up

yeah i also have had (almost) nothing but problems with Dojo's ShrinkSafe, they really should rename that to Tool-That-Blows-Up-In-Your-Face-ShrinkSafe :))

Saeven
22 Aug 2007, 12:57 PM
Ex-dojo victim here too, I've never jumped a better fence than that which leads from Dojo to Ext.

jheid
28 Aug 2007, 1:57 AM
I've just tried the new YUI compressor version 2.0 with ext-all.css. Got it down from 68k to 58k.

What about integrating css compression, too?

matjaz
28 Aug 2007, 2:47 AM
With 2.0 this is also possible. ;)

jheid
28 Aug 2007, 5:23 AM
With 2.0 this is also possible. ;)

What do you mean? Ext 2.0? JS Builder 2.0 or YUI compressor 2.0 (this is what I'm saying...)?

jack.slocum
30 Aug 2007, 3:51 AM
The 1.1.1 build was built with the yui-compressor. It resulted in about 12k drop in file size. I also used it for the CSS. :)

jon.whitcraft
30 Aug 2007, 4:01 AM
I'm currently looking into making the yui-compressor the engine for the Java Builder tool. More will come after i get some time to work on it more after this weekend.

trbs
30 Aug 2007, 7:53 AM
I'm currently looking into making the yui-compressor the engine for the Java Builder tool. More will come after i get some time to work on it more after this weekend.

I will also build the yui-compressor into the Python Builder tool as soon as possible!

(p.s. the most recent version of python tool 0.7.1 is already 800% faster then 0.7.0, if you have the python just-in-time compiler named psyco installed :D )

Condor
30 Aug 2007, 11:29 PM
The YUI Compressor is under heavy developement.
At time of writing the latest version is 2.1.1 and can be obtained from a new url:
http://www.julienlecomte.net/yuicompressor/

mystix
31 Aug 2007, 10:25 AM
yay. add me to the club.

we just switched from ShrinkSafe + Dean Edward's packer to yuicompressor today after i saw trbs's post in the translations thread :D

minifying has never been faster.

trbs
31 Aug 2007, 4:45 PM
Please be aware that for you'll explicitly need to enable --charset utf-8 with yui-compressor to build a completely working extjs.

This is a bug that i've also reported in the Bug Forums for the Ext 1.1.1 build.

Explanation
The locale files use UTF-8 encoding to support many non-ascii languages. The yui-compressor does not automaticly detect the correct character encoding for these files and tries to decode them with a ascii charset. This results in all non-ascii characters being mangled into ascii character 63 - the question mark.

mystix
31 Aug 2007, 10:29 PM
ah just replied to trbs in the bugs thread...

[copied and pasted from bugs]
got this from the YUI Compressor download page (http://www.julienlecomte.net/yuicompressor/):



--charset character-set
If a supported character set is specified, the YUI Compressor will use it
to read the input file. Otherwise, it will assume that the platform's
default character set is being used. The output file is encoded using
the same character set.


HTH

trbs
1 Sep 2007, 5:45 AM
For completeness sake; my Debian Linux appearenly defaults to ASCII as does Jack's Windows Vista machine appearently, since the official build sports the same problem.

steffenk
17 Sep 2007, 12:30 PM
i checked out this one:
http://joliclic.free.fr/php/javascript-packer/en/

it dropped 126kB with ext-all.js - that's incredible!

Animal
18 Sep 2007, 2:02 AM
Yes, but

<span style="Dr. Szell">Is It Safe?</span>

mystix
18 Sep 2007, 2:38 AM
and does it decompress fast (read: fast + low cpu usage) on a normal (read: non-development) machine?

AFAIK, dean edward's packer at max js compression also results in max decompression time.

jon.whitcraft
18 Sep 2007, 2:48 AM
I'm gonna stick with the yuicompressor and gzip file compression on the fly. It does want i need it to and i can sill make out some of the functions for quick debugging.

mystix
18 Sep 2007, 2:58 AM
I'm gonna stick with the yuicompressor and gzip file compression on the fly. It does want i need it to and i can sill make out some of the functions for quick debugging.

agreed. i'm sticking with yuicompressor too.
tried various combinations of ShrinkSafe + Packer before, but they pale in comparison to yuicompressor.

steffenk
18 Sep 2007, 11:59 PM
ok, i run into problems with Dean Edwards 's Packer. Everything worked well: Layouts, dialogs, Accordion - but grid failed.

Animal
19 Sep 2007, 12:37 AM
Dean Edwards' Packer mungs the semantics of the code in some situations.

Check Julien Lecomte's blog entries about the yui compressor.

It does seem like YAHOO is the best option.

steffenk
19 Sep 2007, 1:20 AM
does mootools use Dean Edwards' Packer ? May be they only linked to it.
I think YUI-compressor works best atm. Anyway i will inform Edwards, may be he fixes something.

mystix
26 Sep 2007, 9:57 PM
be careful when compressing with the latest yuicompressor-2.2.1.jar.

one new feature was added


YUI Compressor 2.2.1, 2007-09-25
--------------------------------

+ Optimize quote escaping in JavaScript string literals by using the best quote
character (' or " depending on the occurrence of this character in the string)


which for some strange reason, turned this line in ext-all-debug.js


document.write("<s"+'cript id="ie-deferred-loader" defer="defer" src="/'+'/:"></s'+"cript>");


into


document.write("<s"+"cript id="ie-deferred-loader" defer="defer" src="/"+"/:"></s"+"cript>");

which killed the minified script.

i've tried to inform the author of this. let's hope he replies soon.

steffenk
27 Sep 2007, 7:16 AM
Does anybody have expierience with ESC ? A friend of mine does all his javascript with this compressor, see his page (http://www.malleus.de/)

mystix
28 Sep 2007, 4:43 AM
be careful when compressing with the latest yuicompressor-2.2.1.jar.

one new feature was added


which for some strange reason, turned this line in ext-all-debug.js


document.write("<s"+'cript id="ie-deferred-loader" defer="defer" src="/'+'/:"></s'+"cript>");


into


document.write("<s"+"cript id="ie-deferred-loader" defer="defer" src="/"+"/:"></s"+"cript>");

which killed the minified script.

i've tried to inform the author of this. let's hope he replies soon.

did some more testing.
this works (i.e. yui-compressor-2.2.1 doesn't mess up when minifying ext-all-debug)


document.write("<s"+"cript id='ie-deferred-loader' defer='defer' src='/"+"/:'></s"+"cript>");


but the minified version gets cleverly optimised to


document.write("<script id='ie-deferred-loader' defer='defer' src='//:'></script>");


looks like the only way to preserve the original string is to do this


document.write(["<s",'cript id="ie-deferred-loader" defer="defer" src="/','/:"></s',"cript>"].join(""));


@jack/brian, any thoughts?

scratch all that.
yuicompressor-2.2.2 is out. :)

jheid
29 Sep 2007, 12:35 AM
Just checked the version 2.2.3 with ext-all.js for 2.0 generated from SVN.

Packed by JS Builder 1.1.2.0: 553.967 Bytes
Packed by yuicompressor: 2.2.3.0: 504.785 Bytes

That is at about 9% additional saving.

FonkeyMucker
13 Feb 2008, 10:21 AM
Just checked the version 2.2.3 with ext-all.js for 2.0 generated from SVN.

Packed by JS Builder 1.1.2.0: 553.967 Bytes
Packed by yuicompressor: 2.2.3.0: 504.785 Bytes

That is at about 9% additional saving.


JavaScript Options
--nomunge Minify only, do not obfuscate
--preserve-semi Preserve all semicolons
--disable-optimizations Disable all micro optimizations

If JS Builder is using YUI Compressor, it's probably using the |--nomunge| option. Can anyone confirm?


I like munging; I also like to keep my semis and disable the optimizations like string alteration and converting #FF0000 to red.

Is there a way set these options in JSBuilder?