Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

Re: Compressing/Obfuscating a Javascript file

by andreychek (Parson)
on Oct 06, 2001 at 07:44 UTC ( #117162=note: print w/ replies, xml ) Need Help??

in reply to Compressing/Obfuscating a Javascript file

There is actually already a module which does something like what you're looking for, called HTML::Clean.

There is one big difference between it, and the solution you are working on. Your solution modifies the files directly while still on your disk. It may make them hard to read when you need to maintain them, but no extra processing is required when a browser requests them.. so it may be a bit faster then the method the module uses.

HTML::Clean will leave the code in your files in tact, and modifies the JavaScript code on the fly as the browser requests it. There may be a slight performance hit for this, but I don't really think your users will find it noticable.. but you should probably test that, and not take my word for it :-)

I personally prefer using this module, as it makes code maintenance much easier. However, the best method definitely depends on the requirements of your project. If obfuscation of the source files on your disk is what you're looking for, this might not do the trick. This only "obfuscates" the code as users view it in their browsers. But if you use a regex to obfuscate your code, someone can just as easily use a regex to unobfuscate it :-) Good luck!

Comment on Re: Compressing/Obfuscating a Javascript file

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://117162]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (5)
As of 2015-10-10 17:16 GMT
Find Nodes?
    Voting Booth?

    Does Humor Belong in Programming?

    Results (257 votes), past polls