Skip to content

Instantly share code, notes, and snippets.

@imlinus
Last active December 12, 2016 08:45
Show Gist options
  • Save imlinus/6671d49b7d79f885a4884c202210bd19 to your computer and use it in GitHub Desktop.
Save imlinus/6671d49b7d79f885a4884c202210bd19 to your computer and use it in GitHub Desktop.

Revisions

  1. Linus Lilja revised this gist Dec 12, 2016. No changes.
  2. Linus Lilja created this gist Dec 12, 2016.
    11 changes: 11 additions & 0 deletions compress_page
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@
    <?php
    function compress_page($buffer) {
    $search = array("/<!–\{(.*?)\}–>|<!–(.*?)–>|[\t\r\n]|<!–|–>|\/\/ <!–|\/\/ –>|<!\[CDATA\[|\/\/ \]\]>|\]\]>|\/\/\]\]>|\/\/<!\[CDATA\[/" => "");
    $buffer = preg_replace(array_keys($search), array_values($search), $buffer);
    return $buffer;
    }

    ob_start('compress_page');
    // Page here
    ob_end_flush();
    ?>