new version of JavaScript minifier in Perl

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Peter Michaux

    #1

    new version of JavaScript minifier in Perl

    Hi,

    I've uploaded a new version of the JavaScript::Min ifier 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. :)



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

    Peter

  • -Lost

    #2
    Re: new version of JavaScript minifier in Perl

    Peter Michaux wrote:
    Hi,
    >
    I've uploaded a new version of the JavaScript::Min ifier 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. :)
    >

    >
    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.

    Comment

    • Tom Potts

      #3
      Re: new version of JavaScript minifier in Perl

      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?

      Comment

      • Peter Michaux

        #4
        Re: new version of JavaScript minifier in Perl

        On May 29, 4:06 am, Tom Potts <madtom1...@yah oo.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

        Comment

        • Tom Potts

          #5
          Re: new version of JavaScript minifier in Perl

          >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.

          Comment

          Working...