NOVINKA: Získej 40 hodin praktických dovedností s AI – ZDARMA ke každému akreditovanému kurzu!
S účinností od 26. 3. jsme aktualizovali Zásady zpracování osobních údajů – doplnili jsme informace o monitorování telefonických hovorů se zájemci o studium. Ostatní části zůstávají beze změn.

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