Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save bewho/8d44236d679a07dce6544ed0b97e496f to your computer and use it in GitHub Desktop.
Save bewho/8d44236d679a07dce6544ed0b97e496f to your computer and use it in GitHub Desktop.
Compress HTML file in wordpress theme to increase loading speed of wordpress site
// Minify HTML codes when page is output.
add_action('wp_loaded','my_minify_html');
function my_minify_html(){
/**
* use html_compress($html) function to minify html codes.
*/
ob_start('html_compress');
}
function html_compress($html){
/**
* some minify codes here ...
*/
return $html;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment