Closed felixarntz closed 6 months ago
@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.
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.
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?
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.
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.
@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.
See #897:
Note: Once #946 is merged, this should be implemented against the
feature/modules-to-plugins
branch.