So i thought to myself, that we could truncate the JS and CSS files by removing the unwanted spaces and characters.
So i began writing a script that does the following:
- Reads JS or CSS files(s) from a particular folder called either js or css.
- Removes all the unwanted characters and blank spaces.
- Creates a new file in a new directory called js_cache or css_cache.
- Wallla!! we have done it, you have successfully reduced the file file size.
We can say that the performance is better but not the best, but it works.
You would see a slight reduce in time between the server and the client.
Therefore always use multi line comments like /* comment */ if you want to use this script
- Create a folder for you project
- Dump all the js files in js folder and css files in css folder
- Then create two more folders js_cache and css_cache
- Copy and paste this script in the project directory
- Edit the script by changing the constant FILE_TYPE as js or css only
- Run the script
- New files will be created in js_cache and css_cache
- Wow, its done now use these file instead of the original one
ALL THE BEST…
Do keep sharing!!!