function minifyhtml_minify in Minify Source HTML 7
Helper function to minify HTML.
Parameters
string $page: The entire html source of the page.
7 calls to minifyhtml_minify()
- MinifyHtmlUnitTestCase::testMinifyHtmlIframeReplacement in tests/
minifyhtml.test - Test Minify HTML Iframe Replacement.
- MinifyHtmlUnitTestCase::testMinifyHtmlPreReplacement in tests/
minifyhtml.test - Test Minify HTML Pre Replacement.
- MinifyHtmlUnitTestCase::testMinifyHtmlScriptReplacement in tests/
minifyhtml.test - Test Minify HTML Script Replacement.
- MinifyHtmlUnitTestCase::testMinifyHtmlStripComments in tests/
minifyhtml.test - Test Minify HTML Comment Stripping.
- MinifyHtmlUnitTestCase::testMinifyHtmlStyleReplacement in tests/
minifyhtml.test - Test Minify HTML Style Replacement.
2 string references to 'minifyhtml_minify'
- minifyhtml_exit in ./
minifyhtml.module - Implements hook_exit().
- minifyhtml_form_system_performance_settings_alter in ./
minifyhtml.module - Implements hook_FORM_ID_alter().
File
- ./
minifyhtml.module, line 171 - Hook and helper functions for the Minify HTML module.
Code
function minifyhtml_minify(&$page) {
$callbacks = array(
'minifyhtml_placeholder_callback_textarea' => '/\\s*<textarea(\\b[^>]*?>[\\s\\S]*?<\\/textarea>)\\s*/i',
'minifyhtml_placeholder_callback_pre' => '/\\s*<pre(\\b[^>]*?>[\\s\\S]*?<\\/pre>)\\s*/i',
'minifyhtml_placeholder_callback_iframe' => '/\\s*<iframe(\\b[^>]*?>[\\s\\S]*?<\\/iframe>)\\s*/i',
'minifyhtml_placeholder_callback_script' => '/\\s*<script(\\b[^>]*?>[\\s\\S]*?<\\/script>)\\s*/i',
'minifyhtml_placeholder_callback_style' => '/\\s*<style(\\b[^>]*?>[\\s\\S]*?<\\/style>)\\s*/i',
);
// Only strip HTML comments if required.
if (variable_get('minifyhtml_strip_comments', TRUE)) {
$callbacks['minifyhtml_remove_html_comment'] = '/<!--([\\s\\S]*?)-->/';
}
foreach ($callbacks as $callback => $pattern) {
$content = minifyhtml_minify_callback($pattern, $callback, $page);
if (!is_null($content)) {
$page = $content;
}
}
// Minify the page.
minifyhtml_minify_html($page);
// Restore all values that are currently represented by a placeholder.
global $_minifyhtml_placeholders;
if (!empty($_minifyhtml_placeholders)) {
$page = str_replace(array_keys($_minifyhtml_placeholders), array_values($_minifyhtml_placeholders), $page);
}
}