-
Notifications
You must be signed in to change notification settings - Fork 215
Mini Cart block: exclude already-printed scripts from scripts to lazy load #8979
Mini Cart block: exclude already-printed scripts from scripts to lazy load #8979
Conversation
|
The release ZIP for this PR is accessible via: Script Dependencies ReportThere is no changed script dependency between this branch and trunk. This comment was automatically generated by the TypeScript Errors Report
🎉 🎉 This PR does not introduce new TS errors. |
|
Size Change: 0 B Total Size: 1.11 MB ℹ️ View Unchanged
|
61326df to
8a5ee8d
Compare
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.
Hi @Aljullu,
The code changes look good to me, but while following testing instructions, I am seeing:
- All Products block page: wcBlocksMiniCartFrontendDependencies['wp-i18n'] is undefined.
- Page with no blocks: wcBlocksMiniCartFrontendDependencies['wp-i18n'] is defined
Maybe I am doing something wrong while testing on my local setup? 🤷🏻♂️
Screen.Recording.2023-04-07.at.11.48.21.AM.mov
My bad, that was me writing the testing steps incorrectly. 🤦♂️ What you can reproduce is the expected behavior:
I updated the testing steps accordingly. Sorry for the confusion! 🙏 |
|
@Aljullu, no problem. Thanks for the clarification and updating the testing steps. I'm going to approve it now since I've already tested it 🙂 |
imanish003
left a comment
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.
LGTM 🚀🙌🏻
8e7c188 to
f98cb43
Compare
The Mini Cart block registers an object (
scripts_to_lazy_load) where we store all scripts that we need to lazy load. This PR makes it a bit more clever, so if a script is already printed (ie: another block has enqueued it), it will not be added to the scripts to lazy load.Testing
User Facing Testing
Object.keys( wcBlocksMiniCartFrontendDependencies ).lengthandwcBlocksMiniCartFrontendDependencies['wp-i18n'].wcBlocksMiniCartFrontendDependencies['wp-i18n']is defined.wcBlocksMiniCartFrontendDependencies['wp-i18n']is undefined andObject.keys( wcBlocksMiniCartFrontendDependencies ).lengthis smaller.WooCommerce Visibility
Changelog