-
Notifications
You must be signed in to change notification settings - Fork 206
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
Whitelist user-defined pathnames #26
Comments
Would like to see this too - a predefined list of url's that prefetch would be user than adding attributes to specific links would be easier to implement |
@gauravkg15 is this the same as issue #18? Here's an example of the PR #29 will look like: <html>
<body data-instant-whitelist-mode>
<a href="#1" data-instant>Instant link</a>
<a href="#2">Not an Instant link</a>
</body>
</html> |
My interpretation (or preference anyway!) is that you could whitelist some domains, rather than having to add an attribute to every link you want prefetched. For example, I have two websites, and I would like links on either of them to be prefetchable by the other, by just adding their domains to a whitelist instead of having to add an attribute to every link. |
But then how to you expect to define a set of destination URLs <html>
<body data-instant-whitelisted-url-regex="^(https://domain-1.com|https://domain-2.com/pokemons)">
<a href="https://domain-1.com/" data-instant>Instant link</a>
<a href="https://domain-2.com/pokemons/pikachu">Instant link</a>
<a href="https://domain-2.com/regions">Not an Instant link</a>
<a href="https://domain-3.com/pikapika">Not an Instant link</a>
</body>
</html> Or do you expect to use it in JS way? |
@atilacamurca This isn't the same as that issue #18. The crux of the problem is that adding attributes to every anchor is hard to scale, especially on dynamically generated ones from templating engines. It would be very helpful to just whitelist certain pathnames that you know are for fetching data, and not for triggering some action on your backend. A solid way of accomplishing this is to encapsulate the module in a class, and provide a constructor you can pass an array into. Would work the same, except you would just need to add one line to 'activate' the functionality. Kind of like footable, |
You can currently define a list of links to preload in a variable, then iterate over each link in your page and add a There’s not much of a need to make it a real option, so that’s not planned. |
I plan on adding something along the line of |
Goal: Only allow prefetching links with certain (origin + pathname) defined by the user
Why: Adding the 'data-no-instant' attribute is hard to scale. Some endpoints can trigger actions without query params so its much easier just to define a static list of whitelisted pathnames.
The text was updated successfully, but these errors were encountered: