![]() A SHORT NOTE ABOUT THE DESIGN OF THE MINIFIER CLASSES To a file, then use a text editor to view them. To get sure, you can use the MinifyTo or MinifyFileTo methods to write the minified contents This is not a bug of the class, but simply a problem of rendering minified contents in a browser. ![]() In the case of a web page, you have to be aware that the minified contents will be rendered by your browser this means you could notice that some text disappeared, some extra newlines have been added, etc. ![]() They can either be run as command-line scripts or as web pages. The examples that you will find in the examples/ directory display the contents of a minified example file. Minifying a Javascript file would not require too much modifications : require ( 'JavascriptMinifier.phpclass' ) The following example minifies a CSS file, example.css, and outputs the minified contents on the standard output : require ( 'CssMinifier.phpclass' ) Įcho $minifier -> Minify ( 'example.css' ) Minifying a file is not complicated you can for example minify string or file contents, and get the result as a minified string contents or writing it back directly to an output file. ![]() Composer is a prerequisite for running the tests.The Minifier package is a set of classes aimed at minifying CSS, Javascript, Php and HTML contents.Īdditional langages may be supported, since the abstract Minifier base class provides some support methods for that.Īll Minifier classes ( CssMinifier, JavascriptMinifier, PhpMinifier and HtmlMinifier) provide the same methods to the caller, since they inherit from the abstract Minifier class.PS: you can use the "nocompress"-tag to keep the html e.g.: "\n foobar \n" Unit Test class="lall" => class=lall $htmlMin-> doRemoveOmittedHtmlTags() // remove ommitted html tags e.g. */ $htmlMin-> doOptimizeViaHtmlDomParser() // optimize html via "HtmlDomParser()" $htmlMin-> doRemoveComments() // remove default HTML comments (depends on "doOptimizeViaHtmlDomParser(true)") $htmlMin-> doSumUpWhitespace() // sum-up extra whitespace from the Dom (depends on "doOptimizeViaHtmlDomParser(true)") $htmlMin-> doRemoveWhitespaceAroundTags() // remove whitespace around tags (depends on "doOptimizeViaHtmlDomParser(true)") $htmlMin-> doOptimizeAttributes() // optimize html attributes (depends on "doOptimizeViaHtmlDomParser(true)") $htmlMin-> doRemoveHttpPrefixFromAttributes() // remove optional "http:"-prefix from attributes (depends on "doOptimizeAttributes(true)") $htmlMin-> doRemoveHttpsPrefixFromAttributes() // remove optional "https:"-prefix from attributes (depends on "doOptimizeAttributes(true)") $htmlMin-> doKeepHttpAndHttpsPrefixOnExternalAttributes() // keep "http:"- and "https:"-prefix for all external links $htmlMin-> doMakeSameDomainsLinksRelative() // make some links relative, by removing the domain from attributes $htmlMin-> doRemoveDefaultAttributes() // remove defaults (depends on "doOptimizeAttributes(true)" | disabled by default) $htmlMin-> doRemoveDeprecatedAnchorName() // remove deprecated anchor-jump (depends on "doOptimizeAttributes(true)") $htmlMin-> doRemoveDeprecatedScriptCharsetAttribute() // remove deprecated charset-attribute - the browser will use the charset from the HTTP-Header, anyway (depends on "doOptimizeAttributes(true)") $htmlMin-> doRemoveDeprecatedTypeFromScriptTag() // remove deprecated script-mime-types (depends on "doOptimizeAttributes(true)") $htmlMin-> doRemoveDeprecatedTypeFromStylesheetLink() // remove "type=text/css" for css links (depends on "doOptimizeAttributes(true)") $htmlMin-> doRemoveDeprecatedTypeFromStyleAndLinkTag() // remove "type=text/css" from all links and styles $htmlMin-> doRemoveDefaultMediaTypeFromStyleAndLinkTag() // remove "media="all" from all links and styles $htmlMin-> doRemoveDefaultTypeFromButton() // remove type="submit" from button tags $htmlMin-> doRemoveEmptyAttributes() // remove some empty attributes (depends on "doOptimizeAttributes(true)") $htmlMin-> doRemoveValueFromEmptyInput() // remove 'value=""' from empty (depends on "doOptimizeAttributes(true)") $htmlMin-> doSortCssClassNames() // sort css-class-names, for better gzip results (depends on "doOptimizeAttributes(true)") $htmlMin-> doSortHtmlAttributes() // sort html-attributes, for better gzip results (depends on "doOptimizeAttributes(true)") $htmlMin-> doRemoveSpacesBetweenTags() // remove more (aggressive) spaces in the dom (disabled by default) $htmlMin-> doRemoveOmittedQuotes() // remove quotes e.g. * * Protected HTML (inline css / inline js / conditional comments) are still protected, * no matter what settings you use.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |