Hi,
thanks for sharing that.
I gave it a test run, and got these results:
original file: File size 35kb well commented code.
crunch level 1= 27 kb, code still readable.
crunch level 2= 25 kb, code still readable.
crunch level 3= 25 kb, code wrapped.
crunch level 4= 23 kb, code wrapped.
crunch level 4= 22 kb, variable substitution, code wrapped.

At crunch level 2 the code was still readable, and functional, so for my use
that looks like the best setting.
Comment removal worked very well, even nested comments etc.

Regarding variable substitution, I would actually prefer to be able to
specify in a list which variables I would like to substitute with what,
rather than specifying which ones NOT to change.

For those having trouble running the code, you can also paste it in a .bat
file, saves typing :o)
I made a file crunch.bat , and in it put:

cscript.exe ESC.wsf -l 2 -o newFile.js OriginalFile.js

It's definitely a tool that would allow us to comment the DynAPI code more
fully.

There's an error in line 42 of the readme file , level 1 doesn't do empty
line removal.

Cheers,
Richard Bennett

[EMAIL PROTECTED]
www.richardinfo.com
(Everything running on, and ported to DynAPI2.51)
visit the DynAPI homepage (and FAQ) ::
http://dynapi.sourceforge.net/dynapi/index.php?menu=1
Browse (and search) the mailinglist here:
http://www.mail-archive.com/index.php3?hunt=dynapi



----- Original Message -----
From: "thomas@jet" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, May 09, 2001 4:09 AM
Subject: [Dynapi-Dev] OT: Scriptcompressing


Hi all.

I am normally a lurker on this list cuz I like some of  the topics raised
here once in while dealing
with more complex javascript concepts like memory handling, prototype
techniques etc.

Anyways, there was a thread here a while ago about compressing scripts for
boosting download performance,
and I thought some of you might be interested in checking out this tool I've
put together for this purpose.
The tool is JScript-class wrapped in a command line interface for use under
WSH (Windows Scripting Host).

Story:
We are building a unihost ECMA scripting API overhere and we wanted to have
the ability to create optimized
script-packets out from various external javascript-classes depending on
purpose. Kindof like a 'compilation' phase.
Since there was no such tool available/good enough we made our own, namely
ESC. (ECMAscript Cruncher).

While at it, we decided to bring compression a step further than just to
remove whitespace, so I added a
'variable-substitution' engine to kill off even more bytes. To describe this
simple I'd better say obfuscation,
eventhough this is only the bi-product of the result, the issue here is
lesser chars. This mode is a bit tricky
to get accustomed to at first, since it may crack your script. But once one
understand how it operates, this
thing really rocks cuz it'll save another 5-10% sizewise.(depending on the
src)

The ESC-class gives the opportunity to have a developer version of a
module/class/script with really descriptional
variable- names / method names, commented allover. This dev version of the
script can at any point be 'compiled'
to an optimized chunk for productional use.


ESC has the ability to compress one or multiple external scripts and pack
them together in a single file.
There are four levels of compressions as of now whereas:
0 : none
1 : Empty line, single and Multiline comment removal. (with JScript
conditional compilation awareness)
2 : Removal of whitespace ( string and regexp aware)
3 : Newline removal (with automatic
'often-forgotten-function-compound-seperator' (;) insertion)
4 : Enable variable substitution engine. (keyword, statement and window
top-level prop/methods aware)
!!! The var-subst engine can be used sepatately by using a special cmdline
switch, so it can also be applied at crunch-level : 0.

ESC needs Win32 with WSH 2.0 and JScript 5.5 installed to score, since it
hevealy relies on new features
 in JScript 5.5's RegExp engine. If are running Win 98SE, ME or 2k with MSIE
5.5 installed you should
have the means to run ESC out of the box. Otherwize, the necessary upgrade
of WSH / JScript package
can be obtained from microsoft's (ca. 630 kB) (link provided in the readme
file)

--
ok, enough blabbering, it's freeware so try it out if you like. (...and tell
me if you have found another script-compressor
that can handle a simple thing as 'return -1' :) )
its for ECMAscript developers �  la advanced, so I figure this list is a
good place to point this tool to get it tested/evaluated ;)
Any comments, problems, suggestions or bugreports are welcome.
/thomas.



Thomas Loo / Saltstorm.
[EMAIL PROTECTED]
------------------------------------------------------





_______________________________________________
Dynapi-Dev mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/dynapi-dev

Reply via email to