Skip to content

Instantly share code, notes, and snippets.

@dipesh711
dipesh711 / php-html-css-js-minifier.php
Created Jul 2, 2018 — forked from tovic/php-html-css-js-minifier.php
PHP Function to Minify HTML, CSS and JavaScript
View php-html-css-js-minifier.php
<?php
// Based on <https://github.com/mecha-cms/extend.minify>
define('MINIFY_STRING', '"(?:[^"\\\]|\\\.)*"|\'(?:[^\'\\\]|\\\.)*\'');
define('MINIFY_COMMENT_CSS', '/\*[\s\S]*?\*/');
define('MINIFY_COMMENT_HTML', '<!\-{2}[\s\S]*?\-{2}>');
define('MINIFY_COMMENT_JS', '//[^\n]*');
define('MINIFY_PATTERN_JS', '/[^\n]+?/[gimuy]*');
define('MINIFY_HTML', '<[!/]?[a-zA-Z\d:.-]+[\s\S]*?>');
You can’t perform that action at this time.