任何好的Zend Framework + Minify实现? [英] Any good Zend Framework + Minify implementations?

查看:74
本文介绍了任何好的Zend Framework + Minify实现?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Minify 与Zend Framework的集成是否存在良好的实现?我在找例子.

Are there any good implementations of Minify integration with Zend Framework? I'm looking for examples.

我很想拥有一个覆盖$ this-> headLink()的插件,并吐出正确的缩小的url/内容.

I'd love to have a plugin that overrides $this->headLink() and spits out the correct minified url/content.

我发现大多数示例似乎都没有以一种形式或一种方式进行完全优化.我正在寻找一种满足以下要求的解决方案:

It seems most examples I find aren't fully optimized in one form or fashion. I'm looking for a solution that meets the following requirements:

将多个链接和脚本标记减少到一个请求(一个用于链接,一个用于脚本) 我看到的最接近的是一个请求路径,该路径将逗号分隔的字符串传递给/min/,如下所示:

Reduces multiple links and script tags to one request (one for link and one for scripts) The closest I've seen is a request path that passes a comma-delimited string to /min/ like so:

<script src="/min?f=file1.js,file2,js,file3.js" type="text/javascript"></script>

为什么不将所有脚本动态地组合到磁盘上的一个文件中,然后将其缓存,这样您就不必对每个请求都进行压缩了?

Why not something that combines all scripts into one file on disk on the fly and then caches it so that you aren't doing the minification on every request?

<script src="/js/app.js?someRandomStringHere" type="text/javascript"></script>

合并方面应保持顺序(参考前置,附加等)

The combining aspect should maintain order (in reference to prepend, append, etc)

尽管我不太在乎发送正确的Expires标头,因为我在服务器端强制执行gzipping,etags和Expires标头,但是使用该可选选项将对其他用户有利.

While I don't care so much about sending correct expires headers because I force gzipping, etags, and expires headers on the server-side, having that optional would be beneficial to other users.

最后,只要有一个易于生成的构建脚本来生成最小化资产,就没有必要了-只要它易于执行且不需要在每次构建后都进行代码更改.

Lastly, having a build script that generates the minified assets isn't necessary bad - as long as it is easy to do and doesn't require a code change after every build.

推荐答案

mmm,抱歉,我没有示例,但我可以帮助您解释如何使用

mmm , sorry i don't have examples but i can help you explaining how ,

我简单的工作流程如下:

1-作为视图助手 在您的自定义库文件夹中,创建一个扩展my_minify::minify()静态功能的类. 您可以创建一个覆盖headLink()minfy

1- as a view helper in your custom library folder , create a class that extends the static function of my_minify::minify() you may create a viewhelper that override the functionality of both headLink() and minfy class

2-作为插件: 您可以创建运行postdispatch的插件以最小化整个结果视图,更多解释

2- as a plugin : you might create plugin that runs postdispatch to minify the whole resulting view , more explanation

这篇关于任何好的Zend Framework + Minify实现?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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