Compress your Javascript
Published by Unknown on Monday, July 30, 2007 at 9:41 PM.
Some ajax sites have to load lot's of javascript, and it might be spoiling your visitor's viewing experience (especially if they use dial-up).
You can compress you javascript easily, and it can be from just removing whitespace, removing empty lines, removing comments, to renaming variables, rewriting your code, and obfuscation.
So how to get started.
Many javascript compressors use regex based systems, or sometimes they strip all newline characters-which could be a problem if you do not use semicolons on every line.
For the best result, I start out with dojo shrinksafe () which compresses your variables (eg. var somerandomlongvariablename; to var _33; and automatically adds semicolons. for compression, it also removes comments etc.
Then you should try using something like or (enable base64 encode, and if you want- you can try shrink variables)
You can compress you javascript easily, and it can be from just removing whitespace, removing empty lines, removing comments, to renaming variables, rewriting your code, and obfuscation.
So how to get started.
Many javascript compressors use regex based systems, or sometimes they strip all newline characters-which could be a problem if you do not use semicolons on every line.
For the best result, I start out with dojo shrinksafe () which compresses your variables (eg. var somerandomlongvariablename; to var _33; and automatically adds semicolons. for compression, it also removes comments etc.
Then you should try using something like or (enable base64 encode, and if you want- you can try shrink variables)