Hi Guys,
I want to minify HTML in my project. When I do view source code for page ,in the HTML generated, I can see lot of whitespace. I need a way to minify the HTML files (in a way that after minifcation , the size of the HTML should be 30% less than original HTML file.)
note: The scenario mentioned in bracket is secondary, Primary aim is to minify the HTML files
(screenshot below)
Thank You,
Aditya Srivastava
Topics help categorize Community content and increase your ability to discover relevant content.
Views
Replies
Total Likes
Hi @adi411 ,
Please have a look https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/compress-minify-the-html-p...
Thanks,
Views
Replies
Total Likes
Hi,
Please check this blog which explains how to enable the mod_deflate from Apache (dispatcher) https://www.albinsblog.com/2018/09/improve-performance-of-adobe-experience.html which is responsible for compressing other types of documents.
Also check the official documentation about the same: https://experienceleague.adobe.com/en/docs/experience-manager-dispatcher/using/configuring/dispatche...
Hope this helps
@adi411 - While compression can be achived from Dispatcher by enabling gzip as mentioned by others using Apache Dispatcher modules. One other way is to use HTML Compression libraries which gives you flexibility to remove whitespaces, clean CSS, etc.
Check Google's HTML Compressor Java library - https://code.google.com/archive/p/htmlcompressor/
A custom servlet can be written to produce the output:
HttpGet httpGet = new HttpGet(url);
HttpResponse httpResponse = httpClient.execute(httpGet);
String output = httpResponse.getEntity().toString()
HtmlCompressor compressor = new HtmlCompressor();
String compressedHtml = compressor.compress(html);
response.setContentType(ContentType.TEXT_HTML.getMimeType());
response.setStatus(HttpStatus.SC_OK);
response.getWriter().write(compressedHtml);
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies