Get my new tutorials in your inbox every week

Fixed: Custom JavaScript is not allowed AMP, Google Search Console

Google Search console was throwing Custom Javascript is not allowed error for a few of the AMP pages of my WordPress blog. Google was not able to index my AMP pages for my WordPress blog because of this error. The error was that some custom JavaScript and CSS were injected into the AMP pages of my WordPress blog. Upon investigation, I found out that W3 Total cache was injecting minified JS (JavaScript) and CSS (Cascading Style Sheets) links into the AMP pages. This tutorial is basically a guide to fixing the issue.

What are the errors exactly?

Errors showing up in Google Search Console:

  1. Custom JavaScript is not allowed
  2. External stylesheets not supported, except for whitelisted font providers.

What this means is that the Linked AMP version is invalid and it won’t appear in Google Search results. This tutorial covers fixes for both errors.

Check the screenshot below and you might have got the same…

fixed custom javascript is not allowed amp wordpress
linked amp version is invalid

If you do not want to read the rest of the article, I have prepared a step by step video guide on fixing the issue. Have a look at it,

In case you are a super reader then read along to follow the steps.

Custom JavaScript is not allowed amp – Why this error shows up?

Before going there we need to understand,

What is AMP?

AMP (Accelerated Mobile Pages) is an initiative to make web pages faster and more compatible across different devices and browsers. It is lead by AMP Project.

Google supports AMP Project and provides tools and guidance to integrate AMP web pages with Google tools such as Search and Analytics.
You can check if your website is AMP-ready by using Google Search Console. If there are any issues in any of your web pages, an error message will be displayed in the Search Console Dashboard. The most common error that comes is Custom JavaScript is not allowed amp.

Now let’s talk about why this error comes up? Well, AMP pages should be lightweight so that it loads very fast on slow mobile devices. And as such there should be no custom or author-defined JavaScript or CSS in your AMP pages. Whenever Google bots find it, it throws an error.

How to fix?

For W3 Total Cache you need to activate the AMP extension. This will remove all the custom JS and CSS from the AMP pages. Let’s see how.

Step 1

Log in to your WordPress Admin Dashboard and hover your mouse on the Performance menu. I am assuming you have W3 Total Cache plugin installed.

fixed custom javascript is not allowed amp google search console

Step 2

You should see the Extensions option on the menu. Click on it.

fixed linked amp version is not valid  google search console

Step 3

Activate AMP if you have not done it already. W3 Total Cache comes built-in with the extension. You just need to activate it.

fixed external stylesheet not supported amp wordpress google search console

That’s it. Now clear or purge your cache and go back to Google Search Console and do a Live URL testing of your failed AMP page. Check out my video. You should now see that the error is gone and your Linked AMP page is valid now and available for indexing by Google.

linked amp version is valid google search console

Cheers!!

Related articles:

Link to my Youtube video: https://youtu.be/Luy1P1g7BEc

Write a Comment

Your email address will not be published. Required fields are marked *