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]
------------------------------------------------------
esc-0.94.zip