Subscribe to get my new tutorials in your inbox.

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


Related articles:

Link to my Youtube video:

  1. Vishal Jhaveri

    what if i am not using W3 total cache?? I am using Sitegroud SG optimizer plugin for cache.
    I am getting the same error “custom java script not allowed”

    what is the fix if I am not using w3 total cache plugin??

  2. aissa

    i dont have godady host and i dont use W3 total but i still have the problem
    am in namecheap hosting so do u know what we should do 🙂
    i will be thankful 🙂

  3. Kunika

    Hey i did the same, and activate the amp extention in wp total cahche, still facing the same problem. please please help me. I am tired of watching hundreds of videos on youtube.

Write a Comment

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