Omit formatted comments from minification

You can use url variables and a page rule. For example /abc/?nominify. In a page rule for *?nominify turn off html minification.

2 Likes

Brilliant, I didn’t even think of that.

*<SNIP>/*?nominify
Auto Minify: CSS & JS only

This worked great.

1 Like

Keeping comments is critical when distributing Vue 3 server-rendered pages. Vue 3 uses

<!--[--><some-component/><another-component/><!--]-->

to denote fragments. When these comments are removed, hydration will fail. We are currently maintaining a page that embeds Vue 3 SSG fragments into an existing JSP-based page that would very much benefit from minification.

Adding to this and considering these comments are very short and would affect a potentially a lot of Vue pages, I wonder if it would make sense to just add similar handling here as for <!--[if IE 6]> comments by default without configuration. As Nuxt is now out of beta, there will be more and more pages that use server-rendered Vue 3.

+1 for leaving HTML comments. Laravel Livewire will really like this since the auto minify is removing key formatted HTML comments that Livewire is generating for its components. When it happens, Livewire throws warnings and it is not good in the eyes.

1 Like

This just cost us about two days of three people debugging.

==> Removing whitespace and comments will brake Vue’s hydration strategy when using server side rendering.

In opposite, this means that you basically can’t use Cloudflare with a vue or nuxt project using ssr.

1 Like

In the interim, you can just use a Page Rule to exclude HTML from Auto Minify specifically.

1 Like

+1 for an option to disable comment removal.

As stated above, this is problematic with Nuxt and Vue and breaks SSR hydration. It’s crucial for us that this is implemented, since we cannot use Vue SSR applications with Cloudflare otherwise.

1 Like

I have same problem. Minification remove necessary comments in HTML code. Example:

<!--noindex-->
...
<!--/noindex-->

We require this feature very much please work and it and roll it out. We use angular SSR, we’re failing to use cloudflare due to this issue.