Jefferson Santos's Portfolio

Jefferson Santos's Portfolio

Freelancer Programmer

WordPress HTML Minify

Depending on the plugin and how many are active, this can cause slowness problems in WordPress. For those who like programming and want to compress the HTML file, here’s a hint on how to do this without installing any plugin.

Edit the functions.php file (that is inside your templates folder) and add the following line codes:

functions.php

// minify html
function wp_html_minify_finish($html){
    return new WP_HTML_Minify($html);
}
// add to buffer the wp_html_minify_start
function wp_html_minify_start(){
    ob_start('wp_html_minify_finish');
}
add_action('get_header', 'wp_html_minify_start');

For do that, you need to get all code of the class “WP_HTML_Minify” on Github.

I hope you enjoyed.

DROP A COMMENT

Your email address will not be published. Required fields are marked *