Disabling loading pages via XHR #116

Open
fahad19 opened this Issue Jul 27, 2016 · 8 comments

Projects

None yet

4 participants

@fahad19
Contributor
fahad19 commented Jul 27, 2016

First of all, many many thanks for this awesome project! It looks so beautiful, I couldn't resist myself from using it for a new project of mine. Really well done!


The issue

I came across a very rare issue. When there are links for the same domain, but not of the docs itself, there is an XHR failure, and the UI keeps on loading.

Real life example

For example, in this page https://fahad19.github.io/tydel/examples/counter/index.html, if you click on Source, it will not load.

The docs are hosted in https://fahad19.github.io/tydel/, and I am trying to link to https://fahad19.github.io/tydel-demos/. GitHub Pages of two separate repos.

Possible solution

I believe, if the linked URL does not start with https://fahad19.github.io/tydel/ (with an ending slash), we should not try to load it via XHR and just go to that URL directly.

@rstacruz
Contributor

Ahh, right. That functionality is provided by pjax which docpress-base uses.

The fix might be to simply not load URL's that start with http://, which i guess can be done with elements: 'a:not([href^="http://"])'. Would this be enough for you?

@rstacruz
Contributor

Also I see you're using docpress-rsc haha. I take it you weren't a fan of the default theme?

@fahad19
Contributor
fahad19 commented Jul 28, 2016

@rstacruz: just wanted to mention, the real life example wouldn't work any more, now the domain name is http://tydel.js.org, while demo urls are at https://fahad19.github.io/tydel-demos/counter

Your docpress-rsc theme is super cool! I just tweaked it a bit for hiding the search icon on top left, and sub-headers in sidebar nav. really really like your taste in typography :)

The fix might be to simply not load URL's that start with http://, which i guess can be done with elements: 'a:not([href^="http://"])'. Would this be enough for you?

Sounds good for me 👍 . Even though I would not be affected by this issue any more, but someone else might face it sometime.

@rstacruz
Contributor

bump, looks like I forgot this.

@knownasilya
Contributor

Related issue #138

@Kikobeats
Member

I think that this is a good intermediate solution:

https://github.com/Easyfood/pageAccelerator#how-to-use

adding data-pageAccelerator="false" you disable the injection, so you can control what do you want to be injected.

@Kikobeats
Member

pageAccelerator looks lightweight, but currently I prefer use http://instantclick.io/ because you can add blacklisting links easily:

It may sometimes be more convenient to blacklist a group of links, instead of adding data-no-
instant attributes to all of them.

To blacklist all links in a parent element, add data-no-instant to that element.

http://instantclick.io/blacklisting

Also it supports blacklisting dynamically.

@rstacruz
Contributor
rstacruz commented Sep 25, 2016 edited

I haven't seen instantclick before but the premise looks very interesting.
But yes: it'd be nice to have some sort of opt out mechanism.

@rstacruz rstacruz referenced this issue in docpress/docpress-base Jan 2, 2017
Open

Pjax: don't match external links #186

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment