jafaircl / gatsby-plugin-amp

Gatsby plugin for creating AMP pages
34 stars 32 forks source link

Custom javascript is not allowed | error in custom-element #25

Open kalwalt opened 5 years ago

kalwalt commented 5 years ago

i receive this Amp error: Custom javascript is not allowed it point to this line:

<script async="" custom-element="amp-img" src="https://cdn.ampproject.org/v0/amp-img-0.1.js">

maybe because add the ="" after async?

page to check: https://amp-feature--gatsby-starter-i18n-bulma.netlify.com/it/amp/

https://github.com/kalwalt/gatsby-starter-i18n-bulma/pull/110

kalwalt commented 5 years ago

I didn't solved yet this issue. I also recevie thi error in the console:

GET https://cdn.ampproject.org/v0/amp-img-0.1.js net::ERR_ABORTED 404
amp.js:157 Powered by AMP ⚡ HTML – Version 1909141409590 https://deploy-preview-110--gatsby-starter-i18n-bulma.netlify.com/it/amp/
document-register-el…ent.patched.js:1221 Uncaught (in promise) DOMException: Failed to execute 'define' on 'CustomElementRegistry': the name "amp-img" has already been used with this registry
    at x.Wc.x.define (https://cdn.ampproject.org/v0.js:67:486)
    at Kj (https://cdn.ampproject.org/v0.js:290:763)
    at wj.kd (https://cdn.ampproject.org/v0.js:542:58)
    at vj (https://cdn.ampproject.org/v0.js:249:837)
    at rj.Se (https://cdn.ampproject.org/v0.js:253:112)
    at https://cdn.ampproject.org/v0.js:253:319
5
The resource <URL> was preloaded using link preload but not used within a few seconds from the window's load event. Please make sure it has an appropriate `as` value and it is preloaded intentionally.
​

Maybe it is related to the order of plugins or some conflicts with some other gatsby plugin?

kalwalt commented 5 years ago

It seems that this was caused because i had a wrong pathIdentifier, in gatsby-config.js i changed:

+ pathIdentifier: '/amp/'
- pathIdentifier: '/amp'

The error Custom javascript is not allowed disappear from the Amp validator but i face another issue. in the non amp page i have the correct amphtml link:

<link rel="amphtml" href="https://gatsby-starter-i18n-bulma.netlify.com/it/amp/">

but in the amp page i haven't the canonical link instead i have:

<link rel="amphtml" href="https://gatsby-starter-i18n-bulma.netlify.com/it/amp/amp/">

and i don't have the amp tag in the html tag.

jonoirwinrsa commented 5 years ago

@kalwalt adding a "/" to the end of the path in createPages and leaving pathIdentifier as it was worked for me

kalwalt commented 5 years ago

@kalwalt adding a "/" to the end of the path in createPages and leaving pathIdentifier as it was worked for me

thank you @jonoirwinrsa it worked for me too, though i have another issue related.

jonoirwinrsa commented 5 years ago

@kalwalt what is the issue you have now?