WordPress SEO By Yoast Plugin is interfering with a custom function code – how to troubleshoot and fix it?

We got it working by changing the hook:

add_action( 'wp_loaded', 'wp_html_compression_start' );