Magento:缩小 HTML 输出?
magento中是否有任何文件可以输出所有html?
我想缩小所有 html 输出。
Is there any file in magento where all html will be output?
I want to minify all html output.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
Magento 使用响应对象发送所有输出。
所有输出都添加到该对象,然后调用其
sendResponse
方法。如果您想更改输出,请为
http_response_send_before
事件设置一个侦听器然后在观察者中您可以获取并设置正文
如果您感兴趣,可以在
sendResponse 中调用此事件以下类的
方法和输出本身在以下类的
sendResponse
和outputBody
方法中发送Magento uses a response object to send all output.
All output is added to this object, and then its
sendResponse
method is called.If you want to alter the output, setup a listener for the
http_response_send_before
eventAnd then in your observer you may get and set the body
If you're interested, this event is called in the
sendResponse
method of the following classand the output itself is sent in the
sendResponse
andoutputBody
methods of理想情况下,您希望在缓存输出之前执行缩小操作,以避免过于频繁地执行此操作。我能想到的最好的地方是覆盖
Mage_Page_Block_Html
并将以下函数添加到您的新类中:这样它会对整个页面执行一次操作,然后返回的值可能会被 Magento 缓存在这是通常的方式。它不会单独在每个块上执行,这可能会降低效率。
Ideally you want to perform minification before the output is cached to avoid doing it too often. The best place I can think of is by overriding
Mage_Page_Block_Html
and adding the following function to your new class:This way it performs the action once for the whole page, the returned value may then be cached by Magento in it's usual manner. It's not performing on each block individually which might be less efficient.
您始终可以使用 ob 函数来获取 index.php 中的输出,然后根据需要处理内容。但我怀疑它是否会像启用 gzip 或 deflate 一样增强您的网站
you can always use ob functions to get the output in index.php and then do with the content whatever you need. but i doubt if it will boost your site as much as enabling gzip or deflate
也许来自 Google 的 mod_pagespeed ?这将为你透明地做到这一点。 +1 表示 gzip 和 deflate 两种方式。
Maybe mod_pagespeed from Google? That would do it transparently for you. +1 for gzip and deflate either way.
也许来这里的人可能会发现这个 Magento 扩展很有帮助: http:// www.magentocommerce.com/magento-connect/html-minify-by-jemoon.html
Maybe someone coming here might find this Magento extension helpful: http://www.magentocommerce.com/magento-connect/html-minify-by-jemoon.html