I have generated PHP files for cache loading (via file_get_contents() or include() which randomly procedures...) and let's considere this example:
Un-optimized mode or uncached:
What I NOT want to see:
- spaces between
<body>
and<head>
- spaces between closed tags:
/> <script
or<table> <tr>
What I WANT to see (optimized way using PHP maybe PREG_REPLACE
):
- trimed spaces between tags
<body><head>
- trimed spaces between closed tags:
/><script
or<table><tr>
For above full example should be as RESULT such as:
<!DOCTYPE><head><link href="/static/css/main.css" rel="stylesheet" type="text/css"><title>Title</title><meta http-equiv='Content-Type' content='Type=text/html; charset=UTF-8'> <meta name="description" content="Description site" /><meta name="keywords" content="keywords, another keywords" /><script type="text/javascript" src="/static/js/jquerymin.js"></script></head><body><div id="center_box"><div id="orderdata"><table></table></div><div id="orderform"><form method="post" action="/frontacp" method="post" action="/frontacp" method="post" action="/frontacp" method="post" action="/frontacp"><div class="logincol"><div class="leftcol"><label for="types_name">Tip proizvoda</label></div><div class="rightcol"><input type="text" name="types_name" /></form></div></div></body></html>
Instead BAD (unoptimized usage) of page:
<!DOCTYPE><head>
<link href="/static/css/main.css" rel="stylesheet" type="text/css"><title>Title</title>
<meta http-equiv='Content-Type' content='Type=text/html; charset=UTF-8'> <meta name="description" content="Description site" /><meta name="keywords" content="keywords, another keywords" /><script type="text/javascript" src="/static/js/jquerymin.js"></script></head>
<body><div id="center_box">
<div id="orderdata">
<table>
</table>
</div>
<div id="orderform">
<form method="post" action="/frontacp" method="post" action="/frontacp" method="post" action="/frontacp" method="post" action="/frontacp"><div class="logincol"><div class="leftcol"><label for="types_name">Tip proizvoda</label></div><div class="rightcol"><input type="text" name="types_name" /></form> </div>
</div></body></html>
Solutions: PHP example to trim this problem using in properly method and wan't trim spaces inner HTML tags.
Notice: I have done about reading cache and rendering this question would not cover in this area.
Thank you.