How to optimize the webpage loading speed is a problem. yahoo once made 36 optimizations. In fact, there are still many ways to optimize web pages. The following describes how to increase the loading speed of the front-end by reducing the page size:
PHP compresses html webpage code (clear spaces, line breaks, tabs, comment tags ).
There is a good way to compress HTML. Compression of html is actually: clear line breaks, clear tabs, and remove comment marks. The role it plays cannot be underestimated.
PHP compression HTML functions are now provided. Please try it. It feels good.
No nonsense. Go directly to the Code:
1 <? Php
2 /**
3 * html compression: clear line breaks, clear tabs, and remove comment tags
4 * @ param $ string
5 * @ return $ string after compression
6 **/
7 function compress_html ($ string ){
8 $ string = str_replace ("\ r \ n", '', $ string );
// Clear line breaks
9 $ string = str_replace ("\ n", '', $ string );
// Clear line breaks
10 $ string = str_replace ("\ t", '', $ string );
// Clear the tab www.2cto.com
11 $ pattern = array (
12 "/> * ([^] *) * </",
// Remove the comment mark
13 "/[\ s] + /",
14 "/<! -- [^!] * --> /",
15 "/\"/",
16 "/\"/",
17 "'/\ * [^ *] * \ */'"
18 );
19 $ replace = array (
20 "> \ 1 <",
21 "",
22 "",
23 "\"",
24 "\"",
25 ""
26 );
27 return preg_replace ($ pattern, $ replace, $ string );
28}
29?>
Remove row number
From xiaohanzi