IT rekvalifikace s garancí práce. Seniorní programátoři vydělávají až 160 000 Kč/měsíc a rekvalifikace je prvním krokem. Zjisti, jak na to!
Hledáme nové posily do ITnetwork týmu. Podívej se na volné pozice a přidej se do nejagilnější firmy na trhu - Více informací.

Minifier HTML

php

public function getMinifiedHtml() {
		$html = trim($this->input);

		preg_match_all('/<(pre|code|textarea)(?:(?!<\/\1).)*?<\/\1>/s', $html, $pre);
		$html = preg_replace('/<(pre|code|textarea)(?:(?!<\/\1).)*?<\/\1>/s', '#pre#', $html);

		// Run JavaScript blocks through JSMin.
		$html = preg_replace_callback('/<script(\s+[\s\S]*?)?>([\s\S]*?)<\/script>/i',
			array($this, 'replaceJavaScript'), $html);

		// Run CSS blocks through Minify's CSS minifier.
		$html = preg_replace_callback('/<style(\s+[\s\S]*?)?>([\s\S]*?)<\/style>/i',
			array($this, 'replaceCSS'), $html);

		// Remove HTML comments (but not IE conditional comments).
		$html = preg_replace('/<!--[^[][\s\S]*?-->/', '', $html);

		// Remove leading and trailing whitespace from each line.
		// o.OFIXME: This needs to take into account attribute values that span multiple lines.
		$html = preg_replace('/^\s*(.*?)\s*$/m', "$1", $html);

		// Remove unnecessary whitespace between and inside elements.
		$html = preg_replace('/>\s+(\S[\s\S]*?)?</', "> $1<", $html);
		$html = preg_replace('/>(\S[\s\S]*?)?\s+</', ">$1 <", $html);
		$html = preg_replace('/>\s+</', "> <", $html);

		if (!empty($pre[0])) {
			foreach ($pre[0] as $tag) {
				$html = preg_replace('!#pre#!', $tag, $html,1);
			}
		}

		return $html;
	}

Neformátovaný

Přidáno: 8.7.2014
Expirace: Neuvedeno

Aktivity