如何在运行时缩小JS或CSS [英] How to minify JS or CSS on the fly

查看:142
本文介绍了如何在运行时缩小JS或CSS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在运行时/运行时缩小JS和CSS,以便在运行时/运行时可以在我的服务器中保留原始的代码结构。

How to minify JS and CSS on the fly / runtime, so that I can keep the original code structure in my servers if its minified on the runtime / fly.

推荐答案

我认为你的问题应该是:我如何可靠,可重复更新我的现场服务器?你需要的是一个自动部署脚本。 个人我更喜欢 Fabric ,但还有其他工具可用。

I think your question should actually be: How can I reliably and repeatably update my live servers? What you need is an automatic deployment script. Personally I prefer Fabric, but there are other tools are available.

自动部署脚本将允许您运行单个命令,它将转到活动服务器并更新源代码,运行任何部署步骤(例如缩小javascript)并重新启动网络服务器。

An automatic deployment script will allow you to run a single command which will go to live servers and update the source code, run any deployment steps (such as minifying javascript) and restart the webserver.

't想要在运行中缩小javascript或css文件,你应该在部署时做一次,然后在你的代码中有一个变量,指定这是否是一个实时部署。如果变量为true,那么你的文件链接应该是链接到最小化的版本,如果它是假的,那么他们应该是正常的版本。

You really don't want to be minifying javascript or css files on the fly, you should do that once at deployment and then have a variable in your code that specifies whether this is a live deployment or not. If the variable is true then your links to the files should be links to the minimized version, if it's false then they should be to the normal versions.

的执行最小化的程序,尚未提及的程序是 JSMin

There are a number of programs which perform minimization, one that hasn't been mentioned yet is JSMin.

这篇关于如何在运行时缩小JS或CSS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆