是否有一个插件可以自动缩小和缓存JavaScript? [英] Is there a plugin which will automatically minify and cache JavaScript?

查看:55
本文介绍了是否有一个插件可以自动缩小和缓存JavaScript?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正准备开始一个新项目,我想知道是否有办法在服务器端自动缩小JavaScript,一旦JavaScript缩小了一次就提供缓存?我可以简单地编写一个构建脚本来实现这一目标,但如果我可以通过自动缩小来发射并忘记,那就太好了。在这种情况下,推荐的路线是什么?我应该在花时间上线之前缩小我的JavaScript吗?或者我应该在服务器端寻找能自动为我做的事情吗?

I'm getting ready to start on a new project and I'd like to know if there's a way to automatically minify JavaScript on the server side, providing caching once the JavaScript has been minified once already? I could simply write a build script to accomplish this, but it'd be nice if I could "fire-and-forget" so to speak, with automatic minification. What would be the recommended route in this scenario? Should I minify my JavaScript before it goes online at the cost of time or should I look for something that'll automatically do it for me on the serverside?

我可能会使用Django,但当然,JavaScript和媒体是分开提供的实际的HTML/应用程序输出。

I'll probably be using Django, but of course, JavaScript and media is served separately from the actual "HTML"/application output.

推荐答案

这将取决于您使用的服务器端语言。它与Javascript或Css没什么关系,而是PHP,.NET,Ruby等等。

This will all depend on what server side language you're using. It will have nothing (so much) to do with Javascript or Css, but rather PHP, .NET, Ruby, etc.

注意:这些只是我已经完成了一些快速搜索。我没有任何经验。

  • PHP: How to minify JS or CSS on the fly
  • .NET: Minifying and combining files in .net
  • Ruby: Juicer - a CSS and JavaScript packaging tool

我个人建议 ANY 缩小/在运行时组合,因为服务器端性能命中一次又一次地发生,结束

I personally recommend NOT doing ANY of the minification / combining at run time since there is a server side performance hit that happens over and over and over again.

我的偏好是使用某种构建时间缩小/组合工具来实现目标一次并使服务器只是服务。

My preference is to use some sort of a Build Time minification / combining tool that achieves the goal once and leaves the server to just "serve".

因为我'我为我的IDE运行Visual Studio,我的首选是使用名为 Chirpy 的工具...最终结果是一个静态 site.min.js 文件和一个静态 site.min.css 文件,它包含了我的一切需要。在运行时组合/缩小我的js / css,我将不会受到性能损失。

Since I'm running Visual Studio for my IDE, my preference is to use a tool called Chirpy... the end result is a single static site.min.js file and a single static site.min.css file that has everything I need. I will no longer suffer a performance hit from combining/minifying my js/css at run time.

请务必阅读以下评论,因为它们有助于增加OP所寻求的整体概念。

Be sure to read the comments below, as they help add to the overall concept of what the OP is looking for.

还找到 WebPutty ,看起来像一个漂亮的工具。

Also just found WebPutty, looks like a pretty slick tool.

这篇关于是否有一个插件可以自动缩小和缓存JavaScript?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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