Server-side auto-minify?

前端 未结 4 480
不知归路
不知归路 2020-12-31 10:02

Is there any way to automatically minify static content and then serve it from a cache automatically? Similar to have mod_compress/mod_deflate work? Preferably something I c

4条回答
  •  执念已碎
    2020-12-31 10:24

    I use Microsoft Ajax Minifier which comes with a C# library to minify js files. I use that on the server and serve up a maximum of two minified .js files per page (one "static" one that is the same across the whole site, and one "dynamic" one that is specific to just that page).

    Yahoo's YUI compressor is also a simple Java .jar file that you could use as well.

    The important thing, I think, is not to do it on a file-by-file basis. You really do need to combine the .js files to get the most benefit. For that reason, an "automatic" solution is not really going to work - because it will necessarily only work on a file-by-file basis.

提交回复
热议问题