-
Notifications
You must be signed in to change notification settings - Fork 106
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
Issues on Cart/Checkout, add page exceptions to Speculative Loading plugin #1774
Comments
Are you reporting this after having seen problems with the Cart and Checkout pages? If so, which plugin? |
I'm reporting this after having seen problems with WooCommerce's Cart and Checkout pages. I just edited my report. I temporarily fixed it by preventing the Speculative Loading plugin from being executed on both pages. |
We had previously fixed issues related to WooCommerce:
The issue you're reporting here isn't preloading links which shouldn't be preloaded, but rather that the preloaded content is outdated. So this is indeed something which should be addressed. As a workaround, which you may already be doing, the following should omit Speculation Rules from being printed on the Cart or Checkout pages: add_action(
'wp',
static function () {
if (
( function_exists( 'is_cart' ) && is_cart() ) ||
( function_exists( 'is_checkout' ) && is_checkout() )
) {
remove_action( 'wp_footer', 'plsr_print_speculation_rules' );
}
}
); cc @felixarntz |
Unfortunately, this issue is not limited to the Cart and Checkout pages. If you remove an item from the mini cart in the header, this can result in the item still showing up when going to the cart: Screen.recording.2025-01-07.11.30.58.webmNote in this video that hovering over the header to cause the mini cart to appear is hovering over a link that takes you to the cart. So the prefetch is happening when I first hover over the cart in the header, not when I hover over the button later in the video. |
Therefore, I think a better approach than to disable Speculative Loading from adding the add_filter(
'plsr_speculation_rules_href_exclude_paths',
static function ( $paths ) {
if ( function_exists( 'wc_get_cart_url' ) ) {
$paths[] = wp_parse_url( wc_get_cart_url(), PHP_URL_PATH );
}
if ( function_exists( 'wc_get_checkout_url' ) ) {
$paths[] = wp_parse_url( wc_get_checkout_url(), PHP_URL_PATH );
}
return $paths;
}
); @masvil Please give that a try. If that works, we may need to consider either adding such third-party integrations to the plugin, or else contribute this code to WooCommerce. |
However, @tunetheweb pointed out to me that there is another case that won't be accounted for with this.
At this point, if you open the mini cart you'll see Product A still present even though you removed it before. This situation shouldn't arise as commonly as going to the Cart or Checkout pages, except if immediate eagerness mode was being used in which case it would happen even without needing to hover over the link to Product C above. This issue would be mitigated if WooCommerce would populate the mini cart only when the page displayed via the |
Note also that the contents of the cart are stored in And, if I understand correctly, it seems the mini cart is supposed to be updating whenever the |
SessionStorage is special for Speculation Rules:
|
It works perfectly, also checked on DevTools > Application > Speculation panel.
Pre-built third-party integrations would be fine, but I still think we should be able to manually configure exclusions/inclusions in the plugin at page and URL level to handle any situation (not just WooCommerce and other supported third-party). |
Consider adding page exceptions to Speculative Loading plugin, at least for WooCommerce's Cart and Checkout. Scenarios:
I intentionally created this issue as Bug Report instead of Feature Request.
The text was updated successfully, but these errors were encountered: