April 5, 2017

Featured Image

How to remove render blocking Plusone JavaScript in Blogger

|
Seeing a Google PageSpeed Insights warning for apis.google.com/js/plusone.js? Because Google+ was shut down years ago, this script is completely dead code. Removing it from your Blogger template will instantly eliminate this render-blocking resource and speed up your blog.

Why is plusone.js blocking your Blogger site?

When you run a performance audit, you might see a warning stating: "Your page has 1 blocking script resource. This causes a delay in rendering your page."

The culprit is usually the old Google+ Share button script (plusone.js). 

When a browser hits this script, it pauses loading your text and images to download a file that no longer even exists on Google's servers. 

This unnecessary pause can affect your loading speeds and lower your mobile performance scores.

How to remove render blocking Plusone JavaScript in Blogger

remove render blocking Plusone JavaScript

You can easily get rid of this ghost script using one of the two methods below.


Method 1: Turn off the Blogger Navbar

In older Blogger templates, the default top navigation bar automatically calls the Google+ script. Turning the Navbar off is the easiest way to stop the script from loading.

  1. Log in to your Blogger Dashboard.
  2. In the left menu, click Layout.
  3. Locate the Navbar gadget box and click Edit.
  4. In the configuration window that pops up, scroll to the bottom and select Off.
  5. Click the orange Save button.

Test your site again in PageSpeed Insights. 

If you don't have a Navbar option in your Layout settings, move on to Method 2.


Method 2: Suppress the script injection in your theme HTML

If the script is hardcoded or auto-injected by an older theme layout, you can use a clever HTML comment trick right at the end of your template to neutralize it.

Step 1: Back up your theme

Always download a copy of your theme before editing code. 

Click the arrow next to "Customize" on the Theme page and select Backup.

Step 2: Edit your HTML

  1. Click Edit HTML to open the template code editor.
  2. Click inside the editor, press Ctrl + F (or Cmd + F on Mac), and search for the closing </body> tag.
  3. Replace that standard closing tag with this modified version to comment out the automatic script wrapper:
&lt;!--</body>--&gt;&lt;/body&gt;
  1. Click the Save theme icon in the top-right corner.

Now, check your URL with Google PageSpeed Insights

The dead plusone.js reference will be gone, and your render score will improve.


RELATED PERFORMANCE TIPS: