PHP 클래스 Minify_HTML, minify

This is a heavy regex-based removal of whitespace, unnecessary comments and tokens. IE conditional comments are preserved. There are also options to have STYLE and SCRIPT blocks compressed by callback functions. A test suite is available.
파일 보기 프로젝트 열기: mrclay/minify 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
$_cssMinifier
$_isXhtml
$_jsCleanComments boolean
$_jsMinifier
$_placeholders
$_replacementHash

공개 메소드들

메소드 설명
__construct ( string $html, array $options = [] ) Create a minifier object
minify ( string $html, array $options = [] ) : string "Minify" an HTML page
process ( ) : string Minify the markeup given in the constructor

보호된 메소드들

메소드 설명
_commentCB ( $m )
_needsCdata ( $str )
_removeCdata ( $str )
_removePreCB ( $m )
_removeScriptCB ( $m )
_removeStyleCB ( $m )
_removeTextareaCB ( $m )
_reservePlace ( $content )

메소드 상세

__construct() 공개 메소드

Create a minifier object
public __construct ( string $html, array $options = [] )
$html string
$options array 'cssMinifier' : (optional) callback function to process content of STYLE elements. 'jsMinifier' : (optional) callback function to process content of SCRIPT elements. Note: the type attribute is ignored. 'jsCleanComments' : (optional) whether to remove HTML comments beginning and end of script block 'xhtml' : (optional boolean) should content be treated as XHTML1.0? If unset, minify will sniff for an XHTML doctype.

_commentCB() 보호된 메소드

protected _commentCB ( $m )

_needsCdata() 보호된 메소드

protected _needsCdata ( $str )

_removeCdata() 보호된 메소드

protected _removeCdata ( $str )

_removePreCB() 보호된 메소드

protected _removePreCB ( $m )

_removeScriptCB() 보호된 메소드

protected _removeScriptCB ( $m )

_removeStyleCB() 보호된 메소드

protected _removeStyleCB ( $m )

_removeTextareaCB() 보호된 메소드

protected _removeTextareaCB ( $m )

_reservePlace() 보호된 메소드

protected _reservePlace ( $content )

minify() 공개 정적인 메소드

"Minify" an HTML page
public static minify ( string $html, array $options = [] ) : string
$html string
$options array 'cssMinifier' : (optional) callback function to process content of STYLE elements. 'jsMinifier' : (optional) callback function to process content of SCRIPT elements. Note: the type attribute is ignored. 'xhtml' : (optional boolean) should content be treated as XHTML1.0? If unset, minify will sniff for an XHTML doctype.
리턴 string

process() 공개 메소드

Minify the markeup given in the constructor
public process ( ) : string
리턴 string

프로퍼티 상세

$_cssMinifier 보호되어 있는 프로퍼티

protected $_cssMinifier

$_isXhtml 보호되어 있는 프로퍼티

protected $_isXhtml

$_jsCleanComments 보호되어 있는 프로퍼티

protected bool $_jsCleanComments
리턴 boolean

$_jsMinifier 보호되어 있는 프로퍼티

protected $_jsMinifier

$_placeholders 보호되어 있는 프로퍼티

protected $_placeholders

$_replacementHash 보호되어 있는 프로퍼티

protected $_replacementHash