Remove New Relic JavaScript from WordPress AMP Pages
Having problems with New Relic scripts invalidating your WordPress AMP pages?
Add this to your functions.php file:
/** Disable New Relic Scripts in AMP Pages */ function disable_newrelic_for_amp_pages() { if ( function_exists( 'is_amp_endpoint' ) && is_amp_endpoint() ) { if (extension_loaded('newrelic')) { newrelic_disable_autorum( true ); } } } add_action('init', 'disable_newrelic_for_amp_pages');
We put this into a plugin you can just install if you don’t want to dive into your functions.php file. Download it here or install it from the WP CLI interface:
wp plugin install https://wavemotiondigital.comnew-relic-apm-fix.zip --activate
Only work for me changing the hook “init” for “pre_amp_render_post”
To be clear, this is the code that worked for me. Thanks for the tip Elvis.
/** Disable New Relic Scripts in AMP Pages */
function disable_newrelic_for_amp_pages()
{
if ( function_exists( ‘is_amp_endpoint’ ) && is_amp_endpoint() ) {
if (extension_loaded(‘newrelic’)) {
newrelic_disable_autorum();
}
}
}
add_action(‘pre_amp_render_post’, ‘disable_newrelic_for_amp_pages’);
in the file to functions.php of the theme? the plugins no longer work
Hi! Maybe, you can create a plugin? This one doesn’t work for me anymore
https://wordpress.org/plugins/disabled-newrelic-for-amp/
Since AMP is (basically) dead NS New Relic went from freemium to a purchase required pricing model I think we can safely say this is no longer an issue.