innoweb / silverstripe-minify-html
使用中间件压缩所有前端请求的HTML输出。
2.0.0
2023-03-16 04:10 UTC
Requires
- silverstripe/cms: ^5
- silverstripe/vendor-plugin: ^2.0
- voku/html-min: ^4.5.0
README
概述
使用中间件封装 voku的HTML Compressor和Minifier for PHP 压缩所有前端请求的HTML输出。
需求
- Silverstripe CMS 5.x
- voku/html-min 4
注意:此版本与SilverStripe 5兼容。对于SilverStripe 4,请参阅1版本分支。
安装
使用composer安装模块
composer require innoweb/silverstripe-minify-html dev-master
然后运行dev/build。
配置
配置变量源自voku的库,并调整以与Silverstripe协同工作。以下配置值可用
Innoweb\MinifyHTML\Util\HTMLMinifier:
// Disable all optimisations, e.g. for dev environment
enable_minification: true
// optimize html via voku's "HtmlDomParser()"
optimize_via_html_dom_parser: true
// remove default HTML comments
// (depends on optimize_via_html_dom_parser: true)
// (disabled by default)
remove_comments: false
// sum-up extra whitespace from the Dom
// (depends on optimize_via_html_dom_parser: true)
sum_up_whitespace: true
// remove whitespace around tags
// (depends on optimize_via_html_dom_parser: true)
remove_whitespace_around_tags: true
// optimize html attributes
// (depends on optimize_via_html_dom_parser: true)
optimize_attributes: true
// remove optional "http:"-prefix from attributes
// (depends on optimize_via_html_dom_parser: true)
// (disabled by default)
remove_http_prefix_from_attributes: false
// remove optional "https:"-prefix from attributes
// (depends on optimize_via_html_dom_parser: true)
// (disabled by default)
remove_https_prefix_from_attributes: false
// remove defaults
// (depends on optimize_via_html_dom_parser: true)
// (disabled by default)
remove_default_attributes: false
// remove deprecated anchor-jump
// (depends on optimize_via_html_dom_parser: true)
// (disabled by default)
remove_deprecated_anchor_name: false
// remove deprecated charset-attribute - the browser will use the charset from the HTTP-Header, anyway
// (disabled by default)
remove_deprecated_script_charset_attribute: false
// remove deprecated script-mime-types
remove_deprecated_type_from_script_tag: true
// remove "type=text/css" for css links
remove_deprecated_type_from_stylesheet_link: true
// remove "media="all" from all links and styles
// (disabled by default)
remove_default_media_type_from_style_and_link_tag: false
// remove type="submit" from button tags
// (disabled by default)
remove_default_type_from_button: false
// remove some empty attributes
// (depends on optimize_via_html_dom_parser: true)
remove_empty_attributes: true
// remove 'value=""' from empty <input>
// (depends on optimize_via_html_dom_parser: true)
remove_value_from_empty_input: true
// sort css-class-names, for better gzip results
// (depends on optimize_via_html_dom_parser: true)
sort_css_class_names: true
// sort html-attributes, for better gzip results
// (depends on optimize_via_html_dom_parser: true)
sort_html_attributes: true
// remove more (aggressive) spaces in the dom
// (disabled by default)
remove_spaces_between_tags: false
// remove quotes e.g. class="lall" => class=lall
// (disabled by default)
remove_omitted_quotes: false
// remove ommitted html tags e.g. <p>lall</p> => <p>lall
// (disabled by default)
remove_omitted_html_tags: false
许可证
BSD 3-Clause许可证,请参阅许可证