开发者

How to minify Javascript automatically?

I have many PHP and HTML files. And they have lots of Javascript (jQuery). Is it possible to run some function in PHP or whatever, that that javascript code would be "compressed". Or in other words, minified - automatically? Or开发者_如何学C it is not possible and I have to do that manually (put all that Javascript code in one file and use compressor online or so on)? Thank you.


Unless all of your functions are one-offs, your JS should all be in one file to begin with...or at least all in one file after minimizing.

You can look at PHP-minify as one way to automate things:

http://code.google.com/p/minify/


You can use Ant with YUI Compressor, as described in this post.


You can also use JSMin: https://github.com/rgrove/jsmin-php/


Do look at https://github.com/web-developer/Resource-Handler. This is a on the fly compressor and minifyer for your js. This requires least configuration or hassle, unlike the other one suggested .

RESOURCE HANDLER

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜