简体   繁体   English

如何在Joomla 3中修改磁头输出?

[英]How to modify head output in Joomla 3?

I'm building a custom template using Bootstrap 3 in Joomla 3. I'd like to modify some of the head output - ideally moving some of the JS to the footer for performance, combining some of the generated css files into one, etc... 我正在Joomla 3中使用Bootstrap 3构建自定义模板。我想修改一些头部输出-理想地将一些JS移动到页脚以提高性能,将一些生成的CSS文件合并为一个,等等。 ..

Is there an easy way of doing this? 有一个简单的方法吗? I've used template overrides but no luck - searched but haven't found anything remotely useful except for scripts that unset everything in the head first like a reset. 我使用了模板替代,但是没有运气-搜索但没有发现任何远程有用的东西,除了脚本会首先重置头部中的所有内容(例如重置)的脚本。

Thanks! 谢谢!

There is no way of doing this "easily". 无法“轻松”地执行此操作。

While Joomla does collect all scripts and css before rendering them, a large number of extensions simply output the <script> and <style> tags in the markup. 尽管Joomla在呈现它们之前确实收集了所有脚本和CSS,但是大量扩展只是在标记中输出<script><style>标签。

So the only real solution is to write a system plugin that parses all the resources and performs the optimizations. 因此,唯一真正的解决方案是编写一个系统插件,该插件可以解析所有资源并执行优化。

The best implementation you can find is toomanyfiles , which handles this correctly for css but not completely for js: the issue with js is that you can't simply move all js to the bottom: modernizr and other libraries affect the classes and need to be loaded in the head; 您可以找到的最佳实现是toomanyfiles ,它可以对css正确处理,但对js不能完全处理:js的问题是您不能简单地将所有js移到底部:modernizr和其他库会影响类,因此需要装在头上; and many libraries and frameworks (even bootstrap) have some methods that output markup directly, not to mention document.write() : if this is your case, you'll have to discriminate manually. 许多库和框架(甚至是引导程序)都有一些直接输出标记的方法,更不用说document.write() :如果是这种情况,则必须手动进行区分。

You can get over 95% of what you need from it. 您可以从其中获得超过95%的需求。

An honorable mention goes to JCH Optimize which is even less complete but follows a similar approach. 值得一提的是JCH Optimize ,它虽然不完整,但遵循的是类似的方法。

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

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