SilverCart\Control\MinifiedHTTPResponse
Extension of HTTPResponse to minify the HTML code output.
Based on a SilverStripe 3 extension created by Nivanka Fonseka
(nivanka@silverstripers.com).
This uses a modified version of
https://code.google.com/p/minify/source/browse/min/lib/Minify/HTML.php
- Author: Sebastian Diel <sdiel@pixeltricks.de>
- Copyright: 2018 pixeltricks GmbH
- License: see license file in modules root directory
Synopsis
class MinifiedHTTPResponse
extends HTTPResponse
{
- // members
- private static bool $clean_js_comments = true;
- private static bool $is_xhtml = false;
- private $arrPlaceHolders;
- private $strReplacementHash;
- // methods
- public $this setBody()
- public string MinifyHTML()
- private string reservePlace()
- private string removeCdata()
- private bool needsCdata()
- private string commentCallBack()
- private string removePreCallBack()
- private string removeTextareaCallBack()
- private string removeStylesCallBack()
- private string removeScriptCallBack()
Hierarchy
Extends
- SilverStripe\Control\HTTPResponse
Uses
- SilverStripe\Core\Config\Configurable
Members
private
- $arrPlaceHolders
—
array
Array to store replacement placeholders. - $clean_js_comments
—
SilverCart\Control\bool
Determines whether to remove inline JS comments out the HTML code output. - $is_xhtml
—
SilverCart\Control\bool
Determines whether the HTML code output is XHTML or not. - $strReplacementHash
—
string
Hash to use a replacement placeholder.
Methods
private
- commentCallBack() — Callback method to parse comments.
- needsCdata() — Returns whether the given string needs a <![CDATA[ ]]> section.
- removeCdata() — Removes <![CDATA[ ]]> sections if not necessary.
- removePreCallBack() — Callback method to replace <pre> content with placeholders.
- removeScriptCallBack() — Callback method to minify inline JS and replace <script> content with placeholders.
- removeStylesCallBack() — Callback method to minify inline CSS and replace <style> content with placeholders.
- removeTextareaCallBack() — Callback method to replace <textarea> content with placeholders.
- reservePlace() — Adds a placeholder.
public
- MinifyHTML() — Executes the HTML minification.
- setBody() — Sets the body.