Typically, all popular wordpress themes come with html comments to mark endings of div block. This is required for theme developers as it is much easier to see where particular block ends.
However, I do not like leaving code like that in production site. Although some claim that HTML comments have no effect in SEO, it might have effect in keyword discovery process. Additionally, they might have effect for various security plugins, that filter and block content containing bad words. Third, I think it is bad to leave debug information in production sites.
The biggest problem of these is that WordPress theme frameworks like Hybrid uses these as well. So you will have to clean up frameworks source each time you upgrade your framework. That is not the best approach.
However, You can implement this by creating couple filters in your childs (or custom) theme functions.php file:
function custom_callback($buffer) {
$buffer=preg_replace('/<!--(.*)-->/Ui',' ',$buffer);
return $buffer;
}
function custom_buffer_start() { ob_start("custom_callback"); }
function custom_buffer_end() { ob_end_flush(); }
if (is_user_logged_in() ) {
} else {
add_action('wp_head', 'custom_buffer_start');
add_action('wp_footer', 'custom_buffer_end');
}
This will clean the code from comments when user is not logged in (for search engines and visitors).
Recent Comments