Skip to content

Instantly share code, notes, and snippets.

View plencovich's full-sized avatar

Diego Mariano Plencovich plencovich

View GitHub Profile
@plencovich
plencovich / Compress HTML output.md
Created March 1, 2018 11:25 — forked from natanfelles/Compress HTML output.md
Editing Compress HTML output

Source: https://github.com/bcit-ci/CodeIgniter/wiki/Compress-HTML-output

To remove useless whitespace from generated HTML, except for Javascript see [Regex Source] or just replace the $re value:

$re = '%# Collapse ws everywhere but in blacklisted elements.
        (?>             # Match all whitespaces other than single space.
          [^\S ]\s*     # Either one [\t\r\n\f\v] and zero or more ws,
        | \s{2,}        # or two or more consecutive-any-whitespace.
        ) # Note: The remaining regex consumes no text at all...