Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
kalwalt opened this issue Aug 28, 2019 · 5 comments
Open

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

kalwalt opened this issue Aug 28, 2019 · 5 comments

Comments

@kalwalt
Copy link

kalwalt commented Aug 28, 2019

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/

kalwalt/gatsby-starter-i18n-bulma#110

@kalwalt kalwalt changed the title Custom javascript is not allowed error in custom-element Custom javascript is not allowed | error in custom-element Aug 28, 2019
@kalwalt
Copy link
Author

kalwalt commented Sep 21, 2019

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 added a commit to kalwalt/gatsby-starter-i18n-bulma that referenced this issue Sep 21, 2019
@kalwalt
Copy link
Author

kalwalt commented Sep 21, 2019

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
Copy link

jonoirwinrsa commented Oct 13, 2019

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

@kalwalt
Copy link
Author

kalwalt commented Oct 20, 2019

@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
Copy link

@kalwalt what is the issue you have now?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants