简体   繁体   English

使用 Joomla 的 JCH 优化器缩小 CSS 和 JS 文件

[英]Minify CSS and JS files with JCH optimizer for Joomla

I have installed JCH optimize plugin in Joomla-3 OS property base website to Minify CSS and javascript.我已经在 J​​oomla-3 OS 属性基础网站中安装了 JCH 优化插件来缩小 CSS 和 javascript。

I have activated only Minify CSS and Minify Javascript options, please see the attached file (ss I need these two options to improve in Google PageSpeed Insights)我只激活了 Minify CSS 和 Minify Javascript 选项,请参阅附件(ss 我需要这两个选项来改进 Google PageSpeed Insights)

But I don't see any improvement in Google PageSpeed Insights after Minifying CSS and JS.但是在缩小 CSS 和 JS 之后,我没有看到 Google PageSpeed Insights 有任何改进。

If I activate 'Combine CSS Files' and 'Combine JavaScript Files', it's working fine, but the template has broken format and highlighted text.如果我激活“组合 CSS 文件”和“组合 JavaScript 文件”,它工作正常,但模板格式已损坏并突出显示文本。

As the developer of JCH Optimize, from my experience, most of the problems people experience with the plugin is either from incorrectly configuring the plugin or errors on the website.作为 JCH Optimize 的开发者,根据我的经验,人们在使用插件时遇到的大部分问题要么是插件配置不正确,要么是网站错误。

Every website is different so needs to configured individually so I strongly recommend reading the documentation and tutorials on how to configure and use the plugin before trying to install it on your live site, something a lot of people fail to do.每个网站都不同,因此需要单独配置,因此我强烈建议在尝试将插件安装到您的实时站点之前阅读有关如何配置和使用插件的文档和教程,这是很多人无法做到的。

If you have errors in your javascript file or parsing errors in your css file, while they may seem to work well as individual files you WILL have trouble when these files are combined so it is best to check for these and correct them first.如果您的 javascript 文件中存在错误或 css 文件中存在解析错误,尽管它们可能作为单个文件运行良好,但在组合这些文件时会遇到问题,因此最好先检查这些并更正它们。 Check for javascript errors in your browser's javascript console and you can check for parsing errors in css using http://csslint.net/ .在浏览器的 javascript 控制台中检查 javascript 错误,您可以使用http://csslint.net/检查 css 中的解析错误。 Ignore errors about vendor specific rules like 'Unknown @ rule: @-ms-keyframes'.忽略有关供应商特定规则的错误,例如“未知 @ 规则:@-ms-keyframes”。

However there is ample support and information on the website for users of the plugin at https://www.jch-optimize.net/ .但是,网站上为https://www.jch-optimize.net/上的插件用户提供了充足的支持和信息。 Subscribers can get premium support and assistance in configuring the plugin on your site so no need to post support requests on stackoverflow.订阅者可以在您的站点上配置插件时获得高级支持和帮助,因此无需在 stackoverflow 上发布支持请求。

BTW the answer by itoctopus is incorrect.顺便说一句,itoctopus 的回答是不正确的。 The plugin generates cache based on the name of the files or a hash of the content in inline styles/script, so any content generated on the fly will generate another cache.该插件根据文件名或内联样式/脚本中内容的哈希值生成缓存,因此任何动态生成的内容都会生成另一个缓存。 There's also a tutorial on the site that describes how to handle these kinds of situation to prevent excess cache from being generated.站点上还有一个教程,描述了如何处理这些情况以防止生成过多的缓存。 It would have served him well to read through the documentation before using.在使用之前通读文档对他很有帮助。

We have tried JCH Optimize for a couple of major clients and it was a disaster.我们已经为几个主要客户尝试了 JCH Optimize,但这是一场灾难。 This is because JCH Optimize often caches CSS styles that shouldn't be cached (some CSS styles are generated on the fly), the same goes for JS code.这是因为 JCH Optimize 经常缓存不应该缓存的 CSS 样式(一些 CSS 样式是动态生成的),JS 代码也是如此。

You have 3 options:您有 3 个选择:

  • Disable JCH Optimize on certain extensions (there's a way to do it from JCH Optimize)在某些扩展上禁用 JCH Optimize(有一种方法可以从 JCH Optimize 执行此操作)
  • Completely disable caching on JCH Optimize在 JCH Optimize 上完全禁用缓存
  • Merge those static CSS and JS files yourself自己合并那些静态 CSS 和 JS 文件

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM