datakick Posted June 15, 2023 Posted June 15, 2023 Hi everyone, I just wanted to let you all know that javascript/CSS minification functionality was removed from core. It was replaced with new module tbminifier - this module contains almost identical implementation of original code form core. If you update to bleeding edge, and if you are using CCC functionality, please install this module as well. Otherwise, combined css/js assets would not be minified (but they would still be combined into one big bundle) The reason behind this change is to reduce dependency of core code on third party composer libraries. These dependencies causes a lot of troubles recently. If you install some module that depends the same library (but different version), core version of library will be used because it was loaded first. We know about at least one problematic module -- mollie -- but there will be others as well. Another reasons for this change is to have more flexibility -- you can implement different minification algorithms using different libraries. Who knows, maybe somebody will come up with something new and better. 5
Derbai Posted February 20 Posted February 20 I don't see any differences on the code with the module tbminifier active or disactive. There is something else to be done to minify the html code?
the.rampage.rado Posted February 20 Posted February 20 Same here. In theory nothing more should be done, but yes, my source is also not minified and it looks 'human-readable'. But I'm pretty sure this was the case before the extraction. EDIT: You have to have your module active and then in Performance have those settings as follows:
Derbai Posted February 24 Posted February 24 Hello, I have same settings. So you confirm that the html code is not compressed. Thanks
wakabayashi Posted February 24 Posted February 24 (edited) I don't remember exactly, what I did. But for me it's working (css/js). How is your css file named? Is only one file loaded or multiple? Edited February 24 by wakabayashi
wakabayashi Posted February 24 Posted February 24 Go also under modules->positions and check for this:
datakick Posted February 24 Author Posted February 24 This does not impact HTML code, just CSS and JS
the.rampage.rado Posted February 24 Posted February 24 The module's name is HTML, JS and CSS Minification. I got confused that we always minify HTML and that's why there is no switch in BO.
the.rampage.rado Posted February 25 Posted February 25 Is it worth it to minify html in 2025 at all? I can not test how long does it take for my server to generate me the minified html but here is some breakdown with one 'large' live site and one test install. Live site lacks test with html minification. 0x - large live site 1x - test site with module as is 2x - test site with module modification to 'somewhat' minify html. The result is not very good the minified output can be further processed by online tools. Should we even care for those <20% savings between raw zstd and mini zstd?
Yabber Posted February 25 Posted February 25 15 hours ago, datakick said: This does not impact HTML code, just CSS and JS "tbminifier" module supports actionMinifyHtml hook and in theory the HTML code should be minified. However, for some reason it doesn't work. In Prestashop 1.7 and 8, the smartyOutputContent method of the FrontController class adds support for the actionOutputHTMLBefore hook. And modules that perform HTML minification using this hook work correctly.
datakick Posted February 25 Author Posted February 25 16 minutes ago, Yabber said: "tbminifier" module supports actionMinifyHtml hook and in theory the HTML code should be minified. However, for some reason it doesn't work. In Prestashop 1.7 and 8, the smartyOutputContent method of the FrontController class adds support for the actionOutputHTMLBefore hook. And modules that perform HTML minification using this hook work correctly. The code to minify html can be called using Tools::minifyHTML method, but core does not use this method to post process html code generated by templates. Some modules can still call it directly, though. I'm not sure how useful it is to minify dynamic html content. With CSS and JS we are minifying (mostly) static assets, and generated minified js/css files are saved on filesystem and reused by other http requests. But we can't really cache dynamic html this way, so this overhead could cause more trouble than benefits. CPU and memory usage would probably much higher. This would need some comprehensive performance testing.
the.rampage.rado Posted February 25 Posted February 25 4 hours ago, Yabber said: "tbminifier" module supports actionMinifyHtml hook and in theory the HTML code should be minified. However, for some reason it doesn't work. In Prestashop 1.7 and 8, the smartyOutputContent method of the FrontController class adds support for the actionOutputHTMLBefore hook. And modules that perform HTML minification using this hook work correctly. If it's hooked only to those 3 hooks @wakabayashi mentioned the module does not minify the html. If I modify the module and hook it to header it minifies the html also. In Minify itself there are options to cache the minified files in APCu or OpCode (and others) but I'm unable to understand how to get this to work with negative knowledge. https://github.com/mrclay/minify/tree/master/lib/Minify/Cache and /** * To use APC/Memcache/ZendPlatform for cache storage, require the class and * set $min_cachePath to an instance. Example below: */ //$min_cachePath = new Minify_Cache_APC();
Yabber Posted February 26 Posted February 26 I did HTML minification tests using three different PHP libraries for HTML minification. The server's TTFB time increased by up to 6 times. Also, with dynamically generated HTML pages, this is a feature that brings no benefits. 1
Yabber Posted February 26 Posted February 26 @datakick By the way, I looked at the structure of several wordpress optimization plugins and all of them use this library for CSS and JS minification: https://github.com/matthiasmullie/minify The advantage is that this library does not load any dependent libraries like mrclay/minify. So maybe it is worth converting thirtybees module to this library? 1
datakick Posted February 26 Author Posted February 26 3 minutes ago, Yabber said: @datakick By the way, I looked at the structure of several wordpress optimization plugins and all of them use this library for CSS and JS minification: https://github.com/matthiasmullie/minify The advantage is that this library does not load any dependent libraries like mrclay/minify. So maybe it is worth converting thirtybees module to this library? That was one of the reasons why we moved this functionality from core to the module -- so that developers could create different modules that provide the same functionality (maybe faster, more performant, more configurable...) Unfortunately we don't have enough free capacity to create a new module based on this library.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now