Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make javascript file to min version [duplicate]

Possible Duplicates:
How to organize minification and packaging of css and js files to speed up website?
What do you use to minimize and compress JavaScript libraries?

Hi there

Do you know any tool/method which can help me to minimize the size of a javascript file?

like image 923
Ahmed Youssef Avatar asked Jul 27 '09 08:07

Ahmed Youssef


1 Answers

There are a number of online tools available for minimising your javascript. The following tools all require a download and to be run on your machine:

  1. YUI Compressor
  2. JSMin
  3. ShrinkSafe

These tools allow you to paste in/submit your javascript online and get a minimised version back without having to run any programs on your machine:

  1. Packer
  2. JS Minifier

One potential issue with minimising your javascript is the need to keep a minimised version in your codebase for deployment, and an expanded version for development/maintenance. One way around this is to have your webserver look after compression and minimisation of the files in question. This may lead to some additional overhead on your webserver, but you can address this via cache lifetimes etc.

For Apache, Apache2::Response::FileMerge handles this, and can use JavaScript::Minifier to do the actual minimisation.

On nginx, NginxEmbeddedPerlMinifyJS will do much the same thing.

like image 104
ConroyP Avatar answered Oct 09 '22 01:10

ConroyP