By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,829 Members | 1,828 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,829 IT Pros & Developers. It's quick & easy.

new version of JavaScript minifier in Perl

P: n/a
Hi,

I've uploaded a new version of the javascript::Minifier module that
was on CPAN. It was a translation of JSMin but I rewrote it so it now
handles missing semicolons, + ++ code, and leaves those freaky IE
conditional comments in the output. The goal was that if working code
is input then working code is output where working == working.
Breaking code that works is not such a good idea. :)

http://search.cpan.org/~pmichaux/Jav...pt/Minifier.pm

Just thought someone here might find it useful in their build process.

Peter

May 29 '07 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Peter Michaux wrote:
Hi,

I've uploaded a new version of the javascript::Minifier module that
was on CPAN. It was a translation of JSMin but I rewrote it so it now
handles missing semicolons, + ++ code, and leaves those freaky IE
conditional comments in the output. The goal was that if working code
is input then working code is output where working == working.
Breaking code that works is not such a good idea. :)

http://search.cpan.org/~pmichaux/Jav...pt/Minifier.pm

Just thought someone here might find it useful in their build process.
Thanks!

--
-Lost
Remove the extra words to reply by e-mail. Don't e-mail me. I am
kidding. No I am not.
May 29 '07 #2

P: n/a
Cool.
I was just wondering if javascript would run a lot faster with shorter
variable names - less time to lookup?
If this is the case then does anyone know of a minifier that would be
able to shrink the variable names to something smaller?

May 29 '07 #3

P: n/a
On May 29, 4:06 am, Tom Potts <madtom1...@yahoo.comwrote:
Cool.
I was just wondering if javascript would run a lot faster with shorter
variable names - less time to lookup?
Shorter variable names will reduce download times. However if you gzip
files before serving then the reduction will be minimal because gzip
capitalizes on repeated patterns in a file. The main percentage gain
of minification is removing the comments. If the file will _not_ be
gzipped then there is also a big gain by removing whitespace. If the
file will be gzipped then the gzip handles the whitespace quite well
because it is a repeated pattern.

Shorter variable names won't make the JavaScript run faster because
the JavaScript is compiled when it arrives at the browser.
If this is the case then does anyone know of a minifier that would be
able to shrink the variable names to something smaller?
There are programs that reduce variable name size. This is usually
called obfuscation because it makes the code more difficult to read.
It is more difficult to write an obfuscator and so introducing bugs in
your working code is more likely. Also an obfuscator won't hide the
intention of your code from a reader who really wants to understand
it. Words like function, for, this, document, window, etc are not
normally obfuscated. A major effort would need to be made to obfuscate
these words and the code to unubfuscate it would also be in the
JavaScript (unless flash was used to unobfuscate, I suppose, but even
then the reader could use the flash to unobfusicate the code (it is
futile)).

Peter

May 29 '07 #4

P: n/a
>From what I've read it would seem JavaScript is interpreted in the
browser - everything I've found seems to say 'interpreter' when it
comes to Firefox at least.

May 29 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.