473,804 Members | 4,288 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

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 2549
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. :)

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

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
1675
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 a name from the dropdown box populated by the list in test.txt. Once the user chooses that name, the home directory is then pointed to the chosen name and the user is able to see the files listed in the new directory. I have included the snippet...
3
2472
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 form, do you think it will be slow due to Perl is run under server. How about using JavaSCript to check validation for user input? Do you think it a bit faster?
1
2500
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 out from SQL and display it in an HTML page being generated by perl. I can read the data back in, but can't get it to display. (typically it justs says ) when I refere to the perl variable. Has anyone ANY experience / ideas on how to do this?...
1
1649
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 3 external js files to show a js menu in the header page. Nothing I've tried works and I don't want to monkey with the PERL file. If there is a way to generate the menu, I'd sure appreciate the code because I'm only slightly better at javascript...
2
5307
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" rel="stylesheet"></link> But if i included a .js file like, <link href="../babts/activewidget/styles/xp/aw.css" rel="stylesheet" media="all" type="text/css"> <script src="../babts/activewidget/aw.js"></script>then its not working.
2
2313
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 version before installing Perl 5.8.8? I'm planning to install from source. My box uses Solaris 9. Please help.... Thanks!
11
1585
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 issue: the javascript needs to grab a parameter from the perl information. eg., lets say I need to run javascript that uses a directory name for example, and that directory can change. So I cannot hardcode it...instead, I have a variable called...
10
3826
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 this in perl: system 'export PATH=/usr/java1.6/bin:$PATH'; It works when I just command "export PATH=/usr/java1.6/bin:$PATH" on the shell, but when I run the code I wrote, the sever reposed me: sh:...
2
1619
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 browser not as javascript functionality. My main doubt is how can we write javascript code in perl program?
0
9589
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10340
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10085
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9163
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7626
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6858
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4304
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3830
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3000
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.