Why is Minify Html off by default?

Raw Rob

Free Member
Aug 1, 2009
1,129
236
London/Portugal
I'm setting up a new installation of Magento 2.3.0.

Minify Html is off by default. Anyone know why? I don't know what the downside would be to turning it on.
 
In some (admittedly pretty rare) cases minification can result in invalid code which in the case of HTML would essentially break the store frontend. I would imagine it's disabled as Magento couldn't guarantee it to be 100% error free when it comes to the addition of third party module code, so they supply the tool, but enabling it is at the store owners risk. Basically enable it, then have a good browse of the store to check that all still looks good!
 
  • Like
Reactions: Raw Rob
Upvote 0
It slows down a site increasing TTFB (time to first byte).
Do you mean minification is dynamic? That it takes place as the page is requested?
 
Upvote 0
html minfy is off as it can sometimes cause issues with html rendering, and only needs to be enabled on production / live environments really. It's also easier to work with properly formatted html in the development phase. As soon as the site is live, enable it and test.
 
  • Like
Reactions: Raw Rob
Upvote 0
Do you mean minification is dynamic? That it takes place as the page is requested?

Well, untill a page is full page cached it does take CPU cycles to turn HTML into compressed HTML thus an increase in TTFB.

For pages like cart/checkout/customer area (which are not full page cached) an increase will be there on every page request.
 
Upvote 0
It's also easier to work with properly formatted html in the development phase. As soon as the site is live, enable it and test.
I suspect this is a large part of the reasoning behind keeping minification off by default. It's near-impossible to customise and edit HTML that's been minified; you spend more time trying to work out where one line begins and another ends than you do making any progress development-wise.
 
Upvote 0
I suspect this is a large part of the reasoning behind keeping minification off by default. It's near-impossible to customise and edit HTML that's been minified; you spend more time trying to work out where one line begins and another ends than you do making any progress development-wise.
I highly doubt that.

Chrome dev tools source editor formats your HTML regardless of whether it's minified or not. The other browser HTML inspect tools do the same.
 
Upvote 0
I highly doubt that.

Chrome dev tools source editor formats your HTML regardless of whether it's minified or not. The other browser HTML inspect tools do the same.
Interesting - I wasn't aware the browser dev tools had this functionality. I see you offer a Magento development service so I dare say you're more informed on the subject than I am. Slightly off-topic but is it standard practice to develop using the built in browser tools? Most of my development takes place in desktop text editors so it'd be interesting to see how the pros do it.
 
Upvote 0
It is similar to merging / bundling, minifying of JS and CSS are off by default. It is better to test your site with everything off to find the root cause of performance issues instead of turning everything on and never spot performance issue during development. It also makes debugging easier for developers by keeping everything off by default hence Magento 2 has develop and production mode.
 
Upvote 0

Latest Articles