473,386 Members | 1,817 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

new version of JavaScript minifier in Perl

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
4 2519
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
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
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
>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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Scott Medaugh | last post by:
Hello, I am trying to do something unusual and it has me stumped. I am looking to change the Env variable for RemoteUser essentially. What I would like to happen is that the user would choose...
3
by: phal | last post by:
Hi all; I code Perl for CGI, I using regular expression to check the validation of user input, because the form is small and it run only from my own computer, anyways if many people using my...
1
by: Tufty | last post by:
Hi, I have a webpage that lets the user upload an image. This is the posted to a perl script as a form var. The data is stored in SQL 2005 (as the new image object). I now need to get it back...
1
by: Dave | last post by:
I have "header.html" used by PERL to construct an entire page. Unfortunately, this header page contains no head or body tags; the script generates them. So I am at a loss as to how I can reference...
2
by: umamahi | last post by:
If i use a .js file in HTML then its working. <script src="Y:\Apache\cgi-bin\babts\activewidget\aw.js"></script> <link href="Y:\Apache\cgi-bin\babts\activewidget\styles\xp\aw.css"...
2
by: jrefran | last post by:
Hi yah! Currently, my system has built-in Perl(5.6.1). Actually, there's another version Perl 5.0 when I checked.. Now, I want to upgrade my Perl to Perl 5.8.8. Do I need to remove the previous...
11
by: ahammad | last post by:
Hello, I have a perl file that generates an html file to use on a webpage. I have to add some javascript to the html part of the perl file. I already have some code to do that, but here is the...
10
by: anklos | last post by:
Hi, everyone~ I met a problem: the defualt java version on the unix sever is 1.4, but I'd like to export the 1.6 version on the sever (the 1.6 java exists on the sever) I wrote the code like...
2
by: sasimca007 | last post by:
Hi friends, I have one small doubt that we can write the html code in perl program as saying by content-type: text/html but when i write javascript code that is printing on the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.