Omit formatted comments from minification

I’d like to keep some comments w/in a HTML page that is minified by cloudflare. Credits and ascii art, for examples.
Currently it is said “Inline CSS or JS embedded inside your HTML code will not be minified”.
So a workaround would be to create a style or script tag and put comments in there. I don’t like that idea though.
Something nicer would be:

<!––nomin––>
<!––
Formatted Credits Block
© 2018 bla bla bla
¯\ _ (ツ)_/¯
––>
<!-––/nomin––>

Just like Server-Side-Excludes, cloudflare would parse this section and know not to minify it.

@jules - thanks for this request. It should be possible for us to do this - I’m interested to see if anyone else in the community would use this so please comment if you’re reading and let us know your use-case.

1 Like

A few use cases.

  1. Leaving comments in a public optimized site for remote team members’ help - developers and designers.

  2. Getting our own credit in there, publicly.

  3. Showing a client I built their site with care.

1 Like

Very pretty! If there are other folk who would like this feature please let us know.

1 Like

I would use it for a few things.

  1. Including contact information, especially for security researchers
    (security.txt is starting to help, but there are other times when it can
    be useful to include contact information intended only for a more
    technical audience).

  2. Including credits. These are plainly displayed to users in a
    dedicated page, but I like giving credit to web and graphic designers in
    as many places as possible to make it as easy for a prospective customer
    to contact someone who’s services I use and endorse).

But the one that really matters is mostly for me:

  1. I throw lots of data into comments to help troubleshoot issues. This
    includes which backend server served a response, some details about the
    user’s status. Details like are they logged in? What is their session ID
    or other unique identifier? Were they assigned any special flags (A/B
    testing and similar, which may not be tied to an account or specific
    session if the site doesn’t use these). What is the timestamp when the
    page was generated (for connecting the request to server side logs).

There are tons of other ways to handle this situation, but comments are
relatively easy for semi-technical users to retrieve and send to me, the
instructions are pretty much just “Press CTRL U, copy the top lines
until the ‘Stop copying here’ line, paste into a reply to this email”

1 Like

Another use case… some CMSs and wordpress plugins add comments to the bottom of the page regarding their output and function, so you know it’s working.
CF’s optimization removes them.

So for example I see this in a client’s blog:

But it could / should be this:
23%20PM

Perhaps removing white space and removing comments can be separate options?

1 Like

Another use case:

Lazy-loading iframes.

You then uncomment out the iframe on scroll. Doesn’t work if Cloudflare has removed comments from the DOM.

+1 for this request

Great arguments in this thread. +1

Hello all,

I would also like this to see this feature implemented.
I’m running an AJAX content update functionality that relies on comments for START and END sections like:
image

You may want to try something like this instead:

<div id="content1" class="startContent">
  <p>content1</p>
</div>

… and edit your js appropriately.

+1 for this feature. Most caching plugins for WordPress leave useful information in comments at the end of the markup

+1 for this option

+1 for specific files in the dashboard

+1

I would like comments (of some patterns) to be available so that I can use a Cloudflear Worker to replace them. For example in a production environment it would be good to inject an analytics script via a Worker; in a UAT environment it would be good to inject a UAT banner message via a Worker.

Here is the pattern I would like as an option:

<!--//placeholder name//-->

This feature would also help when using a MVVM frameworks such as Knockout JS.

+1 for leaving html comments.

+1 for some way to leave HTML comments intact.

Hi everyone, I have figured out a workaround with a little hack using conditional comments allowed for IE. IE from versions 5 to 9 allowed conditional code as follows:

<!--[if IE 6]>
  <script>console.log('This runs on IE6);</script>
<![endif]-->

Cloudflare cannot minify that code as it needs to be supported for old IE browsers. So if you create conditional code for a version that does not exist, you can safely serve up comments that will not be stripped by Cloudflare. Boom!

Example below used at https://www.ably.io

2 Likes