0

When I add third-party JavaScript to my AMP website, I get the error below in the console of my browser;

validator.js:526 AMP validation had errors:
validator.js:526 http://127.0.0.1:8887/amp.html:30:4 Custom JavaScript is not allowed. (see https://amp.dev/documentation/guides-and-tutorials/learn/spec/amphtml#html-tags)
validator.js:526 http://127.0.0.1:8887/amp.html:31:4 Custom JavaScript is not allowed. (see https://amp.dev/documentation/guides-and-tutorials/learn/spec/amphtml#html-tags)
<script src="https://a.breaktime.com.tw/js/au.js?spj=zi"></script>

nyedidikeke
  • 6,899
  • 7
  • 44
  • 59
Arthur
  • 9
  • 4
  • 8
    Possible duplicate of [Google AMP best way to write JS script tag](https://stackoverflow.com/questions/36035733/google-amp-best-way-to-write-js-script-tag) – str May 08 '19 at 08:06
  • 1
    If you tell us what exactly you need jQuery for, we can suggest a suitable alternative. –  May 08 '19 at 08:10

2 Answers2

0

The <amp-script> component is the only way to have custom JavaScript in AMP pages while keeping them valid AMP.

The component is currently experimental and relies on the WorkerDOM library to execute JavaScript inside a WebWorker.

fstanis
  • 5,234
  • 1
  • 23
  • 42
-1

Custom javascript or external JS scripts are not allowed in AMP versions its will occurs validations errors

Options : We can able to do what ever with AMP scripts given by (https://amp.dev/documentation/components/)