Re: PHP function to compact javascript code?
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.javascript archive

Re: PHP function to compact javascript code?

From: <andreas.maurer1971@web.de>
Date: Thu Aug 18 2005 - 10:16:41 CEST

Hi,

first of all I'm neither a JavaScript nor a RegExp expert but maybe
with the following steps some of the pros can find a good function to
compact the code:

0) Remove everything from // until the end of the line as long as a
semikolon, maybe with a space before it, is in front of the "//" AND as
long as there is NO escape character in front of the semikolon.
1) Remove all line breaks => you should get a single but very long line
2) Remove 2 or more spaces behind each other and replace them with a
single space => Repeat this step until you have only single spaces
Note: Will cause a problem, if there are two ore more wanted spaces in
a row.
3) Replace everything between /* and */ as long as a semikolon ";" is
directly (maybe followed by a single space) in front of the /* and
there is NO escape character in front of the semikolon.

HTH,

Andy
Received on Tue Oct 18 03:10:10 2005