WordPress or more generally another PHP site? A few days ago we showed you the results speedtests of iGuRu.gr at GTMetix. The rating you saw is the result of hard work and many hours of coding.
Below we will describe the steps to minimize WordPress files and generally any PHP site.
We will need the minify framework from Google Code.
Download Google's minify framework. After λήψη we will have to see where to place it. According to company:
Performing HTML, Inline JavaScript and Inline CSS: we can place the minify PHP framework anywhere ie inside or outside docroot.
In our case we can put it on iguru.gr/min/ in / that is, where it is software of WordPress, but inside the min. The zip already includes a min folder.
So upload with ftp from the file
Η mode Minify PHP functions iguru_minify_html is capable for minimization (minifying) HTML, inline JavaScript, and inline to CSS using minify PHP framework.
Below you need to change the point where you put the script
function iguru_minify_html ($buffer) { if (is_user_logged_in()) { $buffer .= ""; return $buffer; // for logged in users minify is not required } else { $initial = strlen($buffer); $minify_lib_path = '/srv/www/iguru.gr/min'; // use your own path, where you put the minify framework if (!class_exists('Minify_HTML')) { // Line no. 10 & 11 is only applicable to minify v2.1.7 require("$minify_lib_path/lib/Minify/Loader.php"); Minify_Loader::register(); require_once("$minify_lib_path/lib/Minify/HTML.php"); ini_set('include_path', ini_get('include_path').":$minify_lib_path/lib"); require_once("$minify_lib_path/lib/Minify/CSS.php"); require_once("$minify_lib_path/lib/JSMin.php"); } // Calling minify function with HTML content $buffer = Minify_HTML::minify($buffer, array('cssMinifier' => array('Minify_CSS', 'minify'), 'jsMinifier' => array('JSMin', ' minify'))); $final = strlen($buffer); $savings = round((($initial-$final)/$initial*100), 3); $buffer .= ""; return $buffer; } }
And now we can move on, using the above minify mode in WordPress or any application PHP.
Place the above function inside functions.php and you're ready.
You can try your GTMetix page to see the results.
Let us mention that for more correctness and better results you should find someone specialist. iGuRu.gr does not undertake service in case something goes wrong with the above code.
Use it at your own risk.