In order to optimize my website I want to replace several things in a whole HTML. I was able to replace things in the content with the following function:
function replace_text($text) {
$text = str_replace('look-for-this-string', 'replace-with-this-string', $text);
return $text;
}
add_filter('the_content', 'replace_text');
But, for example to minify the generated html I want to delete the line breaks. Is there a way of doing so in functions.php? How can I archive this?