Dynamic Javascript Obfuscator & compression Apache module?

C

Chetan Patil

I would like to obfuscate and compress (remove comments, newlines etc)
my javascript files / ajax code. Is there a module that will do this on
the
fly with some level of caching?

Does such a beast exist?

thx
Gupit
 
E

Erwin Moller

Chetan said:
I would like to obfuscate and compress (remove comments, newlines etc)
my javascript files / ajax code. Is there a module that will do this on
the
fly with some level of caching?

Does such a beast exist?

thx
Gupit

hi,

A bit off topic maybe, but I am curious why you want to obfuscate your JS.
For securitypurposes it is barely a serious option.

Erwin
 
R

RobG

Chetan said:
I would like to obfuscate and compress (remove comments, newlines etc)
my javascript files / ajax code. Is there a module that will do this on
the
fly with some level of caching?

There seems little point in doing it on the fly - do it once, test it, then
publish. Why compress the JS file every single time? It will likely cause
the file to be not cached on the client.

Forget obfuscation, minification is good:

<URL:http://www.crockford.com/javascript/jsmin.html>
 
R

Roman Ziak

RobG said:
There seems little point in doing it on the fly - do it once, test it, then
publish. Why compress the JS file every single time? It will likely cause
the file to be not cached on the client.

Same as for gzip compression on the fly - the server may keep the cache
but I think it does not keep gzip-ed versions of pages on persistent
storage. But different servers may act differently too.
Forget obfuscation, minification is good:

<URL:http://www.crockford.com/javascript/jsmin.html>

There is great compressor from Dean Edwards

http://dean.edwards.name/packer/

But again, the results may vary especially when using the mentioned
on-the-fly gzip compression.

As for the original poster - you do not need Apache module, the job can
be done by server script fetching the original JS file and obfuscating
(or even caching the obfuscated version).

Roman
 
R

RobG

Roman said:
Same as for gzip compression on the fly

I think they are quite different. Servers negotiate whether the client can
accept zipped files or not and may serve either compressed or uncompressed.
For minified JS files, the same file is sent to all clients so the
minified file should be created, tested and used as-is.

Further, a zipped file is much more robust and virtually guaranteed to be
identical when opened by the client. The zip/unzip and negotiation stages
can all be tested and verified, then applied to a general case. The
results of minification aren't, they must be tested by the individual site
and file and therefore can't be applied in general.

the server may keep the cache
but I think it does not keep gzip-ed versions of pages on persistent
storage. But different servers may act differently too.

Yes, in that respect they are the same but so is any cached data.

[...]
 
R

Roman Ziak

RobG said:
I think they are quite different. Servers negotiate whether the client
can accept zipped files or not and may serve either compressed or
uncompressed. For minified JS files, the same file is sent to all
clients so the minified file should be created, tested and used as-is.

This is good point.

I agree that it is a waste of machine time to do that upon every
request. However, with little more sophisticated script, it can do it
once and then only after the file changes again.
Further, a zipped file is much more robust and virtually guaranteed to
be identical when opened by the client. The zip/unzip and negotiation
stages can all be tested and verified, then applied to a general case.
The results of minification aren't, they must be tested by the
individual site and file and therefore can't be applied in general.

Removing comments and white spaces should not affect the javascript.
That's in theory and really depends on the quality of minifier. I did
not use Douglas' minifier, but Dean's packer never failed :)
the server may keep the cache
but I think it does not keep gzip-ed versions of pages on persistent
storage. But different servers may act differently too.

Yes, in that respect they are the same but so is any cached data.

[...]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top