Home > PHP > Optimize HTML code

Optimize HTML code

April 28th, 2013 Leave a comment Go to comments

Here’s a simple way to delete all redundant spaces, lines, tabs, and all the signs that are not visible when viewing the HTML page, but if you watch its source code are very much visible. The result is the HTML code into a single line, which can be reduced by a few KB:

preg_replace("/\s+/", " ", $string);

$string is a variable in which you store the HTML code.

Categories: PHP Tags: ,
  1. No comments yet.
  1. No trackbacks yet.