Exclude rel=nofollow links from prefetch/prerender#1142
Merged
swissspidy merged 3 commits intotrunkfrom Apr 16, 2024
Merged
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
7936258 to
7ce9672
Compare
Co-authored-by: Adam Silverstein <adamjs@google.com>
tunetheweb
approved these changes
Apr 15, 2024
Contributor
tunetheweb
left a comment
There was a problem hiding this comment.
LGTM with one suggestion.
Co-authored-by: Barry Pollard <barrypollard@google.com>
swissspidy
approved these changes
Apr 16, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
WooCommerce has
rel=nofollowon its Add to Cart buttons (which are often links instead ofbuttonelements). These links are not idempotent and they must be excluded from prefech/prerender.Fixes #1140
Relevant technical choices
Alternatively this could have excluded URLs that include the
add-to-cartquery parameter. However, this would seem to be overly-specific to WooCommerce. The issue WICG/nav-speculation#309 was opened by @tunetheweb to consider whetherrel=nofollowlinks should be excluded by default as well, so that is what this PR is going with now as well.Eventually there may need to be a filter in addition to
plsr_speculation_rules_href_exclude_pathswhich applies on the entire speculation rules array so that a plugin can add exclusions which are not URL-specific.Before
{ "prerender": [ { "source": "document", "where": { "and": [ { "href_matches": "/*" }, { "not": { "href_matches": [ "/wp-login.php", "/wp-admin/*" ] } }, { "not": { "selector_matches": ".no-prerender" } } ] }, "eagerness": "moderate" } ] }After
{ "prerender": [ { "source": "document", "where": { "and": [ { "href_matches": "/*" }, { "not": { "href_matches": [ "/wp-login.php", "/wp-admin/*" ] } }, { "not": { "selector_matches": "a[rel=nofollow]" } }, { "not": { "selector_matches": ".no-prerender" } } ] }, "eagerness": "moderate" } ] }