If you’re using Elementor I know you want to see your Google Pagespeed go up. Here’s a quick and easy way to do it. We’ll satisfy Google’s criteria for external links by editing a few lines of the Elementor Plugin code, specifically, the button.php file.
By doing this we’ll satisfy Google’s need for perfection and further our goal of increasing our Pagespeed score.
What we’re changing here is how Elementor treats links that are external (meaning they don’t link to our root domain “www.mysite.com”). The reason we’re changing this is that it is best practice that external links contain the link relationship “nofollow” or “noopener”.
If you’re looking for a better Google Pagespeed score this might just be the ticket that gets you there.
We’ll need to edit the button.php file that is located at wp-content/plugins/elementor/includes/controls/button.php.
Here is the existing code…
if ( $settings['link']['is_external'] ) {
$this->add_render_attribute( 'button', 'target', '_blank' );
}
if ( $settings['link']['nofollow'] ) {
$this->add_render_attribute( 'button', 'rel', 'nofollow' );
}
If You’re Chasing After the Perfect Page Speed Score You’ll Need This…
Using FTP and your favorite text editor (I prefer Notepad++) edit the button.php file by replacing the code above with this code…
if ( $settings['link']['is_external'] && $settings['link']['nofollow'] ) {
$this->add_render_attribute( 'button', 'target', '_blank' );
$this->add_render_attribute( 'button', 'rel', 'noopener' );
} else {
if ( $settings['link']['is_external'] ) {
$this->add_render_attribute( 'button', 'target', '_blank' );
}
if ( $settings['link']['nofollow'] ) {
$this->add_render_attribute( 'button', 'rel', 'nofollow' );
}
}
That’s it folks. I stumbled on this solution on Github. I will link to the original thread when I find it. Send me a message if this solved the issue for you and increased your Google Pagespeed score.