• I am using version 2.3.2 of Autoptimize. One of the CSS files I am adding currently only contains comments and no CSS code.

    Interestingly, Autoptimize combines this CSS file correctly with all the other CSS (which I force in the head), but the comments of this particular CSS file are present in the final CSS output. Comments in all of the other CSS files get removed correctly.

    Currently I fixed the problem by adding a dummy rule to the CSS file.

    However, I believe that a CSS file containing comments only should be minified to an empty string.

Viewing 1 replies (of 1 total)
  • Plugin Author Optimizing Matters

    (@optimizingmatters)

    OK, the problem is that each file is minified separately that AO expects of minification not to be empty. if the result is empty, AO assumes (as we want to minimize the chances of breakage) that the minification failed and uses the unminified version of the CSS instead, hence you see the comments ??

    so yeah, it’s a bug, but I consider it less important then actual breakage of the CSS due to the CSS-minifier failing. you could always hook into the autoptimize_css_after_minify filter to remove comments in the entire aggregated CSS-file (if you’re into development)?

    have a nice weekend,
    frank

Viewing 1 replies (of 1 total)
  • The topic ‘CSS file containing comments only does not get mimized’ is closed to new replies.