Automate mini Javascript / CSS files after upgrade?

I know how to minimize JS and CSS files, but is there a way to automatically minimize these files in a production system? For example, I modify something inside the original JS files and update the production environment. However, when using JS files, it should use an automatic mini version of the JS file (it is advisable to update the current shortened version if the source files were changed).

Given that I work on both Unix and Windows, writing a bash script didn't seem like a plausible idea. Thus, anything that is not OS dependent, or perhaps something that uses PHP for this, would be great. Any suggestions?

+4
source share
2 answers

You can find the value in minify . It uses PHP5 and can sit well on your production server.

From the website:

It combines several CSS or Javascript files, removes unnecessary spaces and comments, and serves them with gzip coding and optimal client cache headers.

+7
source

I agree with @RC, read those existing Q / As.

Other options for your specific question:

  • Post Fixation - Minimization Step
  • Build a step during development, transfer mini files
  • A server-side filter that minimizes file changes (Rails and other frameworks have a built-in interface)
  • Improve your script deployment to minimize during deployment

Write these hooks in cross-platform language instead of bash. (JavaScript, Python, Ruby, etc.).

+3
source

All Articles