Minify HTML Using PHP
icon-search
Minify HTML Using PHP

Minify HTML Using PHP

Minify HTML Using PHP

Decreasing your web page load time and increasing your rankings in Google depends on many factors and one of the factor is cold compression yes, Its it is very helpful in SEO and in rankings that your website should be loaded in less time and your web page size should be small.

you can do that by simply compressing your code here I am having a PHP code for you to compress HTML code.
Copy it, save it and use it.

PHP Code to minify HTML:

<?php
function minifyhtml($filename)  {
$html = file_get_contents($filename);  // Read Entire File
$html = preg_replace('/<!--(?!s*(?:[if [^]]+]|!|>))(?:(?!-->).)*-->/s', '', $html);
$html = str_replace(array("\r\n", "\r", "\n", "\t"), '', $html);
while ( stristr($html, '  '))
$html = str_replace('  ', ' ', $html);
$myfile = fopen($filename, "w") or die("Unable to open file!");  // Create Or open existing file
fwrite($myfile, $html); //write to a file
fclose($myfile);
}
minifyhtml('index.html'); //Execute function
?>

Replace index.html with you html file name.
Disqus Codes

No comments

Notifications

Disqus Logo