Magento: Minify HTML Output?

前端 未结 5 868
一个人的身影
一个人的身影 2020-12-31 15:22

Is there any file in magento where all html will be output?

I want to minify all html output.

5条回答
  •  清歌不尽
    2020-12-31 15:31

    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:

    protected function _toHtml()
    {
        $html = parent::_toHtml();
        // MINIFY CONTENTS OF $html HERE
        return $html;
    }
    

    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.

提交回复
热议问题