How to minify the HTML output in Magento?

How can I find the file where is the HTML output? The goal is to minify it.

Russel Thomas Asked on November 26, 2015 in Magento.
Add Comment
1 Answer(s)
Best answer

If your goal is to edit the output, then you will need to catch the response object which Magento is using to send the output. First you would need to setup a listener ” http_response_send_before”:

<!-- in your module's config.xml -->










Then you can get and set the body in the observer:

class Packagename_Modulename_Model_Observer


public function alterOutput($observer)


$response = $observer->getResponse();

$html = $response->getBody();

//modify html here




The response object is called at “sendResponse” in the class located at:


The output itself is sent to “sendResponse” and “outputBody” methods at:


Russel Thomas Answered on November 26, 2015.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.