-
Notifications
You must be signed in to change notification settings - Fork 219
Prevent Mini Cart loading the same script twice #7794
Conversation
The release ZIP for this PR is accessible via:
|
TypeScript Errors ReportFiles with errors: 429 🎉 🎉 This PR does not introduce new TS errors. |
Size Change: +115 B (0%) Total Size: 972 kB
ℹ️ View Unchanged
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure that this will necessarily address the case we tripped over, as the Page Optimize plugin doesn't actually write out the expected id
or src
attributes for scripts. This may make the checks a bit more robust in general, but I am not sure if it will address the original issue consistently.
Thanks for your deep investigation! I can confirm that with your fix, the
In any case, I think that we should merge #7791 because we register the Mini Cart blocks in wrong way.
@daledupreez, I'm pretty sure that this PR fixes the original issue. Page Optimize adds the I will approve the PR, but feel free to continue the discussion if you have other concerns! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot for your investigation! LGTM! 🚢
Hmm, in my testing I saw two
Can you expand on that? I'm a bit confused when we need to use In any case, I will go ahead merging this PR for now. Thanks for the comments and reviews. 🙂 |
Reading the JSDoc comment, |
* Empty commit for release pull request * Display correct block template when filtering by attribute (#7640) * Fix error when trying to access the queried object when it's null (#7664) * Fix error when trying to access the queried object when it's null. * Check if the `slug` exists * Use the taxonomy name instead of the slug, otherwise it returns false * Update readme changelog * Add testing notes * Improve testing notes format * Bumping version strings to new version. * Prevent Mini Cart loading the same script twice (#7794) * Empty commit for release pull request * update changelog * add testing instructions * update zip file link * Mini Cart: load wc-blocks-registry package at the load of the page instead of lazy load it (#7813) * update changelog * update testing instructions * update zip file link * Bumping version strings to new version. Co-authored-by: github-actions <github-actions@github.com> Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com> Co-authored-by: Alba Rincón <albarin@users.noreply.github.com> Co-authored-by: Alba Rincón <alba.rincon@automattic.com> Co-authored-by: Luigi <gigitux@gmail.com>
* Empty commit for release pull request * Added readme.txt changelog entry * Update HPOS compatibility snippet (#7395) * 8.7.2 Testing notes * Update testing notes * Update testing notes * Bumped version * Refactor force billing: remove forcedBillingAddress from conditions for showBillingFields (#7393) Co-authored-by: Niels Lange <info@nielslange.de> * Updated testing instructions and changelog to include #7393 * Updated testing zip * Bumping version strings to new version. * Empty commit for release pull request * Fix wrong keys being sent in `canMakePayment` and customer data showing in the Checkout block in the editor (#7434) * Construct args for canMakePayment with correct keys * When the CheckoutEventsContext mounts, initialize payment store * Destructure useSelect correctly * Dispatch __internalInitializePaymentStore in selector tests * Update selector name to __internalUpdateAvailablePaymentMethods * Remove check for editor when registering checkout store * Add check for when express payment methods have updated too * Ensure billingAddress key exists in canMakePayment arg * Use editor context to know if we're in editor * Updated readme.txt * Reverted stable tag change on readme.txt * Testing instructions * Cleaned out testing instructions * Bumping version strings to new version. * Empty commit for release pull request * Testing instructions * package-lock.json version bump * Revert "Fix `useForcedLayout` to re-select inner blocks after we manually insert one (#6676)" (#7447) This reverts commit 1564de2. * Testing zip * Bumping version strings to new version. * add testing instructions * upload a new zip file * Update styles of the Filter by Attribute dropdown so it looks good in TT3 (#7506) * Use theme's body background color as the mini cart contents default background color (#7510) Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com> * Price Slider: use `currentColor` for the slider (#7527) * Fixed Price Slider Issue Located where the price slider was hard coded and replaced it. * fix CSS lint * use currentColor instead of hard-coded color for the slider of the Filter By Price block #7130 use currentColor instead of hard-coded color for the slider of the Filte By Price block * use currentColor instead of hard-coded color for the slider of the Filter By Price block #7130 use currentColor instead of hard-coded color for the slider of the Filte By Price block * remove background-color Co-authored-by: EmptySet-Exe <46509186+EmptySet-Exe@users.noreply.github.com> Co-authored-by: Niels Lange <info@nielslange.de> * Make price slider 'inactive' range half transparent so it looks better in dark themes (#7525) * Fix inconsistent button styling with TT3 (#7516) * fix inconsistent button styling with TT3 * use wc_wp_theme_get_element_class_name * add check to be sure that wc_wp_theme_get_element_class_name function exists * Fix Mini Cart Block global styles #7379 (#7515) * Fix Mini Cart Block global styles #7379 Fix Mini Cart Block global styles * add font_size * upload a new build * Bumping version strings to new version. * update changelog * Empty commit for release pull request * add testing instructions * update zip file link * Prevent Mini Cart loading the same script twice (#7794) Co-authored-by: github-actions <github-actions@github.com> Co-authored-by: Paulo Arromba <17236129+wavvves@users.noreply.github.com> Co-authored-by: Alex Florisca <alex.florisca@automattic.com> Co-authored-by: Tarun Vijwani <tarun.vijwani@automattic.com> Co-authored-by: Niels Lange <info@nielslange.de> Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com> Co-authored-by: Luigi <gigitux@gmail.com> Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com> Co-authored-by: Tung Du <dinhtungdu@gmail.com> Co-authored-by: EmptySet-Exe <46509186+EmptySet-Exe@users.noreply.github.com>
This is an alternative approach to fix the issue described in #7791.
The issue seemed to be that we were loading several
wc-blocks-registry
scripts, so we were registering the Mini Cart inner components in one registry, but then trying to fetch them from another registry which was empty. This issue was reproducible with Product Bundles because their script (wc-pb-checkout-blocks
) has a dependency onwc-blocks-checkout
which depends onwc-blocks-registry
.This PR changes the way the Mini Cart block checks if a script has already been loaded in the page to avoid loading it twice. Until now, we were relying on the ids of the
script
elements. But for some reason which I don't understand yet,wc-blocks-registry
isn't getting the proper id. So now, in addition to the previous method, we also check for thesrc
attribute of thescript
elements, so if they are duplicated, we avoid loading (and preloading) the script.As mentioned in #7791, thanks to @gigitux, @nerrad, @senadir, and @daledupreez for helping research this issue.
Testing
Automated Tests
User Facing Testing
WooCommerce Visibility
Performance Impact
Changelog