gan_formatter.php
static function minify_html(&$root, $strip_comments = true, $recursive = true) {
		if ($strip_comments) {
			foreach($root->select(':comment', false, $recursive, true) as $c) {
				$prev = $c->getSibling(-1);
				$next = $c->getSibling(1);
				$c->delete();
				if ($prev && $next && ($prev->isText()) && ($next->isText())) {
					$prev->text .= $next->text;
					$next->delete();
				}
			}
		}
		foreach($root->select('(!pre + !xmp + !style + !script + !"?php" + !"~text~" + !"~comment~"):not-empty > "~text~"', false, $recursive, true) as $c) {
			$c->text = preg_replace('`\s+`', ' ', $c->text);
		}
	}
static function minify_html(&$root, $strip_comments = true, $recursive = true) {
		if ($strip_comments) {
			foreach($root->select(':comment', false, $recursive, true) as $c) {
				$prev = $c->getSibling(-1);
				$next = $c->getSibling(1);
				$c->delete();
				if ($prev && $next && ($prev->isText()) && ($next->isText())) {
					$prev->text .= $next->text;
					$next->delete();
				}
			}
		}
		foreach($root->select('(!pre + !xmp + !style + !script + !"?php" + !"~text~" + !"~comment~"):not-empty > "~text~"', false, $recursive, true) as $c) {
			$c->text = preg_replace('`\s+`', ' ', $c->text);
		}
	}
static function minify_html ( & $ root , $ strip_comments = true , $ recursive = true ) { if ( $ strip_comments ) { foreach ( $ root -> select ( ':comment' , false , $ recursive , true ) as $ c ) { $ prev = $ c -> getSibling ( - 1 ) ; $ next = $ c -> getSibling ( 1 ) ; $ c -> delete ( ) ; if ( $ prev && $ next && ( $ prev -> isText ( ) ) && ( $ next -> isText ( ) ) ) { $ prev -> text .= $ next -> text ; $ next -> delete ( ) ; } } } foreach ( $ root -> select ( '(!pre + !xmp + !style + !script + !"?php" + !"~text~" + !"~comment~"):not-empty > "~text~"' , false , $ recursive , true ) as $ c ) { $ c -> text = preg_replace ( '`\s+`' , ' ' , $ c -> text ) ; } }
Minifies HTML / removes unneeded whitespace
@param DomNode $root
@param bool $strip_comments
@param bool $recursive
Minifies HTML / removes unneeded whitespace