以 Ext JS 作为前端的 Rails 应用程序需要压缩脚本
我有一个使用 Ext JS 作为前端的 Rails 应用程序。 我运行该应用程序没有问题。 但由于 ext-all.js 体积庞大,因此加载需要更多时间。 我尝试构建一个自定义 Ext JS,但这对 Ext JS 脚本的大小没有太大影响。
由于我使用 Rails 2.x,因此我尝试使用 Rails 缓存。 对于普通的java脚本文件,它在缓存中没有问题,但是对于Ext JS脚本,它会加载,但我得到一些DOM对象错误,例如:Ext is not Define
。 我正在寻找的是 Ext JS 脚本的压缩版本或某些 gzip 模式。 我尝试谷歌搜索并找到了各种尝试压缩的选项。 但我还没有破解它。
谁能提供一些关于如何解决压缩问题的指示?
I have a rails application which uses Ext JS for the front end. I have no problem in running the application. But since ext-all.js is bulky, it takes more time to load. I tried to build a custom Ext JS but that did not make much of a difference in size of the Ext JS script.
I was trying to use the Rails cache since I use Rails 2.x. For normal java script files, it has no problem in caching, but for Ext JS scripts, it loads, but I get some DOM object errors such as: Ext is not defined
. What I am looking for is a compressed version of the Ext JS scripts or some gzip mode. I tried googling and found various options to try compression. But am yet to crack it.
Could anyone provide some pointers on how to solve the compression problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
这里解释了自定义构建的各种特定于 Ext 的选项:
http://extjs.com/learn/Tutorial:Building_Ext_From_Source
对于压缩有很多选择。 YUICompressor 是目前最好的之一。 不确定“gzip 模式”是什么意思。 Gzip 是一个应该在 Web 服务器级别启用的选项,与 Ext 或 JavaScript 无关。
Various Ext-specific options for custom builds explained here:
http://extjs.com/learn/Tutorial:Building_Ext_From_Source
For compression there are many options. YUICompressor is one of the best right now. Not sure what you mean by "gzip mode." Gzip is an option that should be enabled at the web server level and has nothing to do with Ext or JavaScript.
Ext 已经在生产文件中缩小,因此进一步缩小是徒劳的,您应该只缩小自己的脚本。
您可以研究 CacheFly,鉴于其分布式特性,它可以更快地为您的客户提供 Ext。
唯一的其他选择确实是使用 Apache 等中的 mod_gzip 进行 HTTP 请求级压缩。
Ext is already minified in the production files so to minify further is futile you should only minify your own scripts.
You could look into CacheFly which may provide Ext to your customers faster given it's distributed nature.
The only other option is indeed to do HTTP request level compression using mod_gzip in Apache or the like.
ExtJs 的大小并不比大多数现代网站大(如果有的话)。 它与您的脚本一起小于 1MB。 而且它只加载一次。 我认为,以目前的网络速度,它对客户几乎没有影响。
ExtJs size is not much bigger (if any) than most of modern web-sites. It's something below 1MB together with your scripts. And it's loading only one time. I think, with the current network speeds it has nearly of no impact for clients.
它实际上是您的网络服务器的配置。
您应该对 Apache 使用类似的内容:
它将确保这些资产被压缩,并且除非另有说明,否则可缓存 30 天。
It's actually a configuration of your web server.
You should use something like this for Apache:
It'll make sure that these assets are compressed and unless specified otherwise - cacheable for 30 days.