diff --git a/core/lib/Drupal/Core/Template/TwigExtension.php b/core/lib/Drupal/Core/Template/TwigExtension.php
index 715fd1e..e010da3 100644
--- a/core/lib/Drupal/Core/Template/TwigExtension.php
+++ b/core/lib/Drupal/Core/Template/TwigExtension.php
@@ -155,6 +155,9 @@ public function getFilters() {
       // Replace twig's escape filter with our own.
       new \Twig_SimpleFilter('drupal_escape', [$this, 'escapeFilter'], array('needs_environment' => TRUE, 'is_safe_callback' => 'twig_escape_filter_is_safe')),
 
+      // Remove html comments
+      new \Twig_SimpleFilter('remove_html_comments', [$this, 'removeHtmlComments']),
+      
       // Implements safe joining.
       // @todo Make that the default for |join? Upstream issue:
       //   https://github.com/fabpot/Twig/issues/1420
@@ -374,6 +377,18 @@ public function escapePlaceholder($env, $string) {
   }
 
   /**
+   * Removes html comments from string.
+   *
+   * @param $string
+   *
+   * @return string|null
+   */
+  public function removeHtmlComments($string) {
+    $output = preg_replace('/<!--(.|\s)*?-->/', '', $string);
+    return $output;
+  }
+
+  /**
    * Overrides twig_escape_filter().
    *
    * Replacement function for Twig's escape filter.
