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

Allow certain URLs to opt out of prerendering while still eligible for prefetching #907

Closed
Tracked by #908
felixarntz opened this issue Dec 15, 2023 · 6 comments · Fixed by #1025
Closed
Tracked by #908
Labels
[Plugin] Performance Lab Issue relates to work in the Performance Lab Plugin only [Plugin] Speculative Loading Issues for the Speculative Loading plugin (formerly Speculation Rules) [Type] Enhancement A suggestion for improvement of an existing feature

Comments

@felixarntz
Copy link
Member

felixarntz commented Dec 15, 2023

See #897:

  • It should be possible for certain URLs to only be excluded from prerendering, but not from prefetching. In other words, if the site is configured to prerender, those URLs would fall back to prefetching. If the site is configured to prefetch, those URLs would just work like any other.

Note: Once #946 is merged, this should be implemented against the feature/modules-to-plugins branch.

@felixarntz felixarntz added [Type] Enhancement A suggestion for improvement of an existing feature [Focus] JS & CSS [Plugin] Performance Lab Issue relates to work in the Performance Lab Plugin only [Plugin] Speculative Loading Issues for the Speculative Loading plugin (formerly Speculation Rules) labels Dec 15, 2023
@felixarntz
Copy link
Member Author

@westonruter @mukeshpanchal27 I think it would be great to implement this soon and ship in a 1.1.0 release.

Thinking about the implementation, I think the most straightforward way would be to rely on the existing plsr_speculation_rules_href_exclude_paths filter and pass an additional $mode parameter to it. That way the callbacks can optionally exclude URL patterns e.g. only if the plugin is in "prerender" mode. WDYT?

In any case, we should also amend the documentation in the FAQ accordingly to explain how to do that.

@westonruter
Copy link
Member

Do we have any examples for when a site would want to opt-out of prerendering while retaining prefetching for a given URL?

As for passing a new $mode to the filter, this seems fine. It could today be achieved by reading the option value instead.

@felixarntz
Copy link
Member Author

Prerendering is more sensitive for some types of content that prefetching, so we had discussed this to be a useful enhancement. I believe @domenic may have some ideas for examples?

@domenic
Copy link

domenic commented Feb 28, 2024

One example is that on my personal site, I prerender all same-origin links, but prefetch cross-origin ones, because only prefetching works cross-origin.

An example of the sort @felixarntz is discussing would be if you haven't made certain parts of your site prerender-ready: e.g., viewing a product page calls client-side JavaScript to update the user's interest database or something like that. So maybe it's fine to prerender all parts of your site except product pages, but you still want to speed up product page loads, so prefetching them is desired.

@westonruter
Copy link
Member

One example is that on my personal site, I prerender all same-origin links, but prefetch cross-origin ones, because only prefetching works cross-origin.

@felixarntz Just to confirm that this specific use case isn't possible with the plugin right now, right? It only includes same-origin links without a filter to also include rules for other origins.

@felixarntz
Copy link
Member Author

@westonruter Correct. That could potentially be another enhancement to open an issue for. It should probably be a separate filter (this one opt-in rather than opt-out) that only applies to prefetching. In other words, even if the site is configured to prerender, those URLs would still prefetched.

I think for this one passing the $mode to the filter will be an intuitive way to contextually exclude paths.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Plugin] Performance Lab Issue relates to work in the Performance Lab Plugin only [Plugin] Speculative Loading Issues for the Speculative Loading plugin (formerly Speculation Rules) [Type] Enhancement A suggestion for improvement of an existing feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants