I've just launched my website, and currently tackling page speed issues.
The most glaring issue is the Deferring of a specific .js file
This file is included with the "Twitch for Wordpress" plugin.
I'm running my site though Cloudflare CDN, which is minifying JS, I have AMP Real URL enabled, Brotli enabled. Gzip is enabled in the W3 Total Cache plugin (should I disable the Cloudflare one?) I have Rocket Loader enabled.
I'm running a slightly modified version of the Escapade Child theme for Primer.
I've tried W3 Total Cache Defer JS(non blocking) and all other non-blocking, I've swapped to use the minify provided by Cloudflare (which handles most, just the one plugin is still blocking, and I'd strongly prefer not to get rid of the plugin, unless there is a better alternative).
I've tried .htaccess
modifications outlined in GTMetrix:
function defer_parsing_of_js ( $url ) {
if ( FALSE === strpos( $url, '.js' ) ) return $url;
if ( strpos( $url, 'jquery.js' ) ) return $url;
return "$url' defer ";
}
add_filter( 'clean_url', 'defer_parsing_of_js', 11, 1 );
<script type="text/javascript">
function downloadJSAtOnload() {
var element = document.createElement("script");
element.src = "https://cdn.collectiveray.com/defer.js"; <!-- Replaced this line with https://player.twitch.tv/js/player.c121e93a8ba044cc73a2.js, no luck -->
document.body.appendChild(element);
}
if (window.addEventListener)
window.addEventListener("load", downloadJSAtOnload, false);
else if (window.attachEvent)
window.attachEvent("onload", downloadJSAtOnload);
else window.onload = downloadJSAtOnload;
</script>
Everything I've tried seemed to have no effect whatsoever. It's still blocking, and some methods break functionality in other ways in the theme itself.
I'm at a loss, And would greatly appreciate any and all assistance.