K
kkkk
from: http://blog.codexpress.cn/javascript/is-javascript-compressor-really-useful/
Does javascript compressor save bandwidth and speed up page load time?
Many developers tend to believe it, but it is probably not the truth.
Nowadays, most mainstream browser and web servers support gzip
deflate. Usually your browser does not have to deal with javascript
text-files directly. Instead, gzipped data are handled between server
and browsers. So I just used gzip to see how much javascript
compressor can reduce file size and load time. Testing file is
Prototype 1.5.1.1; three popular compressor - Dean Edwards' Javascript
Compressor, Dojo ShrinkSafe and MemTronic's HTML/JavaScript Cruncher &
Compressor took this test. The table below shows the result:
Origina Dean Edwards'
ShrinkSafe MemTronic's
file size(kb) 94.0 39.2
64.5 40.4 *
gzipped size(kb) 20.6 16.7
18.4 20.4
* MemTronic's HTML/JavaScript Cruncher & Compressor produce files
containing non-ASCII characters, so I had to save it in UTF-8 format,
which increased the file size.
The biggest difference in file size is less than 4kb. If you are using
a 56k modem, it will take almost a second on average. But this happens
only you first load the page, otherwise the script will be cached by
the browser. However, a compressed javascript file, having no obvious
advantage in file size, will decompress itself each time the page
loads. I don't have an accurate method to evaluate how long it will
take. Even the time for decompressing can be ignored, it will surely
make your CPU occupation a little higher.
Does javascript compressor protect your script source?
Probably not. Compressed scripts need to decompress by themselves.
There always exists "eval()" function to execute the original script.
Just changing "eval" to "document.write", all secrets reveal. A
javascript formatter may be used to get formatted codes. After a few
manual corrections, the compressed script will be perfect for
analyzing and hacking, except that all comments were removed. This
trick usually works.
Obfuscators like Dojo ShrinkSafe will make variable/function names
unreadable. That's the true protection, but it is not always safe.
Some scripts fails to work after the replacement.
Does javascript compressor save bandwidth and speed up page load time?
Many developers tend to believe it, but it is probably not the truth.
Nowadays, most mainstream browser and web servers support gzip
deflate. Usually your browser does not have to deal with javascript
text-files directly. Instead, gzipped data are handled between server
and browsers. So I just used gzip to see how much javascript
compressor can reduce file size and load time. Testing file is
Prototype 1.5.1.1; three popular compressor - Dean Edwards' Javascript
Compressor, Dojo ShrinkSafe and MemTronic's HTML/JavaScript Cruncher &
Compressor took this test. The table below shows the result:
Origina Dean Edwards'
ShrinkSafe MemTronic's
file size(kb) 94.0 39.2
64.5 40.4 *
gzipped size(kb) 20.6 16.7
18.4 20.4
* MemTronic's HTML/JavaScript Cruncher & Compressor produce files
containing non-ASCII characters, so I had to save it in UTF-8 format,
which increased the file size.
The biggest difference in file size is less than 4kb. If you are using
a 56k modem, it will take almost a second on average. But this happens
only you first load the page, otherwise the script will be cached by
the browser. However, a compressed javascript file, having no obvious
advantage in file size, will decompress itself each time the page
loads. I don't have an accurate method to evaluate how long it will
take. Even the time for decompressing can be ignored, it will surely
make your CPU occupation a little higher.
Does javascript compressor protect your script source?
Probably not. Compressed scripts need to decompress by themselves.
There always exists "eval()" function to execute the original script.
Just changing "eval" to "document.write", all secrets reveal. A
javascript formatter may be used to get formatted codes. After a few
manual corrections, the compressed script will be perfect for
analyzing and hacking, except that all comments were removed. This
trick usually works.
Obfuscators like Dojo ShrinkSafe will make variable/function names
unreadable. That's the true protection, but it is not always safe.
Some scripts fails to work after the replacement.