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

Does JS-injected <link rel=amphtml> trigger AMP document discovery? #6080

Closed
ithinkihaveacat opened this issue Nov 8, 2016 · 5 comments
Closed

Comments

@ithinkihaveacat
Copy link
Contributor

https://www.ampproject.org/docs/reference/spec#amp-document-discovery explains that AMP documents are linked with their associated canonicals via the <link rel="amphtml"> tag.

Can JS be used to dynamically inject this code? i.e. via something like:

const e = document.createElement("link");
e.href = 'http://example.com/amp/something';
e.rel = 'amphtml';
document.head.appendChild(e);

(I assume the answer is no, but it might be worthwhile making it clear in the docs.)

@cramforce
Copy link
Member

This depends entirely on the crawler. For some the answer will be that it
works and for some the answer will be that it doesn't work.

On Tue, Nov 8, 2016 at 9:09 AM, Michael Stillwell notifications@github.com
wrote:

https://www.ampproject.org/docs/reference/spec#amp-document-discovery
explains that AMP documents are linked with their associated canonicals via
the tag.

Can JS be used to dynamically inject this code? i.e. via something like:

const e = document.createElement("link");e.href = 'http://example.com/amp/something';e.rel = 'amphtml';document.head.appendChild(e);

(I assume the answer is no, but it might be worthwhile making it clear in
the docs.)


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#6080, or mute the thread
https://github.com/notifications/unsubscribe-auth/AAFeT1Xg0nZthDijPRtZocM6jzTJc3TVks5q8KzBgaJpZM4KsrJX
.

@jridgewell
Copy link
Contributor

Should we clarify this?

@ithinkihaveacat
Copy link
Contributor Author

Not holding @cramforce to this but I just discovered a previous related comment: "Lets just decide that JS injection is not OK." (Nov 2015)

(And yes, I think some sort of clarification (even if it's "crawler-dependent but might work") would be useful.)

@cramforce
Copy link
Member

@ithinkihaveacat Could you send a PR?

@ericlindley-g
Copy link
Contributor

@ithinkihaveacat I think I can close this with the PR merged, but please reopen if there's outstanding work. Thanks!

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

4 participants