Compress/Minify the HTML page ( not the js and css which can do by GZIp) | Community
Skip to main content
ebin_Aby
Level 2
July 6, 2020
Solved

Compress/Minify the HTML page ( not the js and css which can do by GZIp)

  • July 6, 2020
  • 4 replies
  • 6198 views

I intend to compress/Minfy my HTML output so that the html size becomes less which increases the performance . 

 

eg : view-source:https://docs.adobe.com/content/help/en/experience-manager-dispatcher/using/getting-started/dispatcher-install.html 

lots of white space if you see the source code . 

 

 

Best answer by Nirmal_Jose

Hi @ebin_aby ,

 

HTML compression needs to be implemented on your web server. If its Apache, you can use mod_deflate module. Please follow [1] for steps and [2] for documentation

 

[1] - https://knackforge.com/blog/karalmax/how-enable-gzip-compression-apache

[2] - https://httpd.apache.org/docs/2.4/mod/mod_deflate.html

4 replies

vanegi
Adobe Employee
Adobe Employee
July 6, 2020
ebin_Aby
ebin_AbyAuthor
Level 2
July 6, 2020
this is for JS and Css not for HTML
Vaibhavi_J
Level 7
July 6, 2020

Hi @ebin_aby 

AEM OOTB doesn't have default option to minify html. 

Minification option is available for css /js by default . 

 

If you need to minify html output, you need to use html compression library which is custom implementation. 

There are many plugins are available to achieve the minification of html. One of the simplest is 

maven  html compression tag library, which you can import and use it for html minification. 

https://mvnrepository.com/artifact/com.googlecode.htmlcompressor/htmlcompressor/1.4

Or 

You can achieve the same towards apache layer as well. mod-pagespeed is one of the plugin which includes minification/compression of html along with other features which contribute to page performance. You can find more details in below article. 

https://www.modpagespeed.com/doc/build_mod_pagespeed_from_source

ebin_Aby
ebin_AbyAuthor
Level 2
July 6, 2020
Thanks for the inputs .
Nirmal_Jose
Adobe Employee
Nirmal_JoseAdobe EmployeeAccepted solution
Adobe Employee
July 6, 2020

Hi @ebin_aby ,

 

HTML compression needs to be implemented on your web server. If its Apache, you can use mod_deflate module. Please follow [1] for steps and [2] for documentation

 

[1] - https://knackforge.com/blog/karalmax/how-enable-gzip-compression-apache

[2] - https://httpd.apache.org/docs/2.4/mod/mod_deflate.html

oibafarel1987
January 15, 2024

Hi,

I see mod_deflate is for compression not minification. Is there a recommended alternative for minifying the HTML files? We have found many references to mod_pagespeed but the last version of the module was released in 2018 and there is no active development (https://groups.google.com/g/mod-pagespeed-discuss/c/dKz1KKjEII0).

arunpatidar
Community Advisor
Community Advisor
July 6, 2020

I don't think so, removing whitespaces would make much difference in performance. If you have large pages in sizes then it may but for small pages, it may not.

Arun Patidar