Title: Keeping some comments..
Last modified: June 5, 2018

---

# Keeping some comments..

 *  Resolved [dbro](https://wordpress.org/support/users/dbro/)
 * (@dbro)
 * [7 years, 10 months ago](https://wordpress.org/support/topic/keeping-some-comments/)
 * I wanted to keep some comments like <!–googleoff: all–>
 * So I added this code in replacement from the old:
 *     ```
       if ($minify_html_comments != 'no') {
         $process = preg_replace('/(<!--{)(.*)(}-->)/','@#_###{$2}###_#@', $process);
         $process = preg_replace('/<!--(?!\s*(?:\[if [^\]]+]|<!|>))(?:(?!-->).)*-->' . $mod, '', $process);
         $process = preg_replace('/(@#_###{)(.*)(}###_#@)/','<!--$2-->', $process);
       }
       ```
   
 * Then I rewrote the comment as: <!–{googleoff: all}–>
    And now it keeps the comment.
   🙂
 * Just thought I would share.

Viewing 1 replies (of 1 total)

 *  Thread Starter [dbro](https://wordpress.org/support/users/dbro/)
 * (@dbro)
 * [7 years, 10 months ago](https://wordpress.org/support/topic/keeping-some-comments/#post-10364948)
 * Sorry needs to be ungreedy.. use this instead:
 *     ```
       if ($minify_html_comments != 'no') {
         $process = preg_replace('/(<!--{)(.*?)(}-->)/','@#_###{$2}###_#@', $process);
         $process = preg_replace('/<!--(?!\s*(?:\[if [^\]]+]|<!|>))(?:(?!-->).)*-->' . $mod, '', $process);
         $process = preg_replace('/(@#_###{)(.*?)(}###_#@)/','<!--$2-->', $process);
       }
       ```
   

Viewing 1 replies (of 1 total)

The topic ‘Keeping some comments..’ is closed to new replies.

 * ![](https://ps.w.org/minify-html-markup/assets/icon-128x128.png?rev=1354357)
 * [Minify HTML](https://wordpress.org/plugins/minify-html-markup/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/minify-html-markup/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/minify-html-markup/)
 * [Active Topics](https://wordpress.org/support/plugin/minify-html-markup/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/minify-html-markup/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/minify-html-markup/reviews/)

 * 1 reply
 * 1 participant
 * Last reply from: [dbro](https://wordpress.org/support/users/dbro/)
 * Last activity: [7 years, 10 months ago](https://wordpress.org/support/topic/keeping-some-comments/#post-10364948)
 * Status: resolved