instantpage / instant.page

Make your site’s pages instant in 1 minute and improve your conversion rate by 1%
https://instant.page
MIT License
6.04k stars 205 forks source link

Link to external pages #5

Closed batbyR closed 5 years ago

batbyR commented 5 years ago

Hi!

Thanks for your project! ⚡

I am currently using it to quickly render my bookmarks.

But I faced some issue: why do you forbid the redirection to external websites?

 if (urlObject.origin != location.origin) {
    return
  }

Do you think it would be worth adding a website whitelist here? I can submit a PR.

Congratulations for this repo!

jerodev commented 5 years ago

I suppose this is because the project is meant to speed up your own website and not external websites.

However, I do see why this might be useful in some cases. It would be great if this would be configurable, but then again you would need a config and it would no longer be possible to have this functionality by just including a script tag.

batbyR commented 5 years ago

Hi @jerodev,

I see your point.

Can we imagine manually whitelist some external links as we do for query strings?

image

aghorler commented 5 years ago

This would be especially useful for websites broken down into sub-domains (eg. links to signup.example.com instead of example.com/signup).

bashbaugh commented 5 years ago

Also websites might lose visitors when an external website takes too long to load.

dieulot commented 5 years ago

I’m open to it. quicklink’s readme states that cross-origin requests might bring CORB and CORS issues but in my experience they just work. This might be about quicklink’s fallback to Ajax.

I’ve asked quicklink’s Addy Osmani about it on Twitter. If I hear back positively (or don’t hear back) support for external links will be implemented, probably enabled with an attribute such as data-instant-allow-external-links on the <body>.

batbyR commented 5 years ago

Great @dieulot ! 👍

I have updated my pull request according to your implementation.

dieulot commented 5 years ago

Okay, this is in. v1.2.0 will let you allow external links with an data-instant-allow-external-links attribute on the <body> or with a data-instant attribute on the link.