-
Notifications
You must be signed in to change notification settings - Fork 10.7k
Fix: Limit loading legacy single product scripts #60223
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
Conversation
Testing GuidelinesHi @kmanijak , Apart from reviewing the code changes, please make sure to review the testing instructions (Guide) and verify that relevant tests (E2E, Unit, Integration, etc.) have been added or updated as needed. Reminder: PR reviewers are required to document testing performed. This includes:
|
📝 WalkthroughWalkthroughRestricts loading of legacy single-product scripts to legacy/classic blocks by adding block-level enqueue methods and a site-level dequeue on wp_enqueue_scripts; removes prior template-loader conditional for block themes and standardizes several array literal syntaxes to long-form Changes
Sequence Diagram(s)sequenceDiagram
participant Browser
participant WP_Render
participant Block (Classic/ProductDetails/ProductImageGallery)
participant WP_Enqueue_Hooks
participant BlockTemplatesController
Browser->>WP_Render: Request single product page
WP_Render->>Block: render() / render_legacy_block()
Block->>WP_Enqueue_Hooks: add_action('wp_enqueue_scripts', enqueue_legacy_assets, 20)
WP_Enqueue_Hooks->>Block: enqueue_legacy_assets() (on wp_enqueue_scripts)
Block->>WP_Enqueue_Hooks: wp_enqueue_script/style('wc-single-product', ...)
WP_Enqueue_Hooks->>BlockTemplatesController: dequeue_legacy_scripts() (also on wp_enqueue_scripts)
BlockTemplatesController->>WP_Enqueue_Hooks: wp_dequeue_script('wc-single-product') (if conditions met)
WP_Render->>Browser: Respond with final page
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~15–20 minutes Possibly related PRs
📜 Recent review detailsConfiguration used: .coderabbit.yml 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
✨ Finishing Touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
Test using WordPress PlaygroundThe changes in this pull request can be previewed and tested using a WordPress Playground instance. Test this pull request with WordPress Playground. Note that this URL is valid for 30 days from when this comment was last updated. You can update it by closing/reopening the PR or pushing a new commit. |
kmanijak
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.
I followed the steps and can confirm the dependencies are loaded as expected, especially:
- Product Image Gallery dependencies (e.g. flexslider or photoswipe) are loaded only with Classic block or with Product Image Gallery,
single-product.jsis loaded with Classic block or when classic Product Image Gallery or Product Details are in use.
Great job! 💪
Side question, I see you're changing [] into array() - is that done automatically by your linter or you do it manually? If so, why? Is there any benefit of array() over []?
Yeah, it's auto-formatted by my editor. I need to see why it didn't follow our ruleset. I deleted that change manually probably three times for this PR 😅 , let me remove it. |
…ich is for classic themes
0a5861d to
20d11ad
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.
Actionable comments posted: 0
🧹 Nitpick comments (2)
plugins/woocommerce/src/Blocks/BlockTypes/ProductImageGallery.php (2)
30-31: Revert array syntax to align with project standards.The change from
[]toarray()contradicts the established WooCommerce coding standards. Per the PR objectives, this was unintended auto-formatting.- return array( 'query', 'queryId', 'postId' ); + return [ 'query', 'queryId', 'postId' ];
48-73: LGTM! Comprehensive legacy asset management.The method properly handles legacy script requirements:
- Enqueues all necessary scripts (zoom, flexslider, photoswipe)
- Includes required styles (photoswipe-default-skin)
- Adds photoswipe template to footer
- Enables required filters for zoom, photoswipe, and flexslider functionality
The intentional duplication with
ClassicTemplate.phpis well-documented and aligns with the PR's independence strategy for legacy blocks.However, consider the array syntax consistency:
- add_action( 'wp_enqueue_scripts', [ $this, 'enqueue_legacy_assets' ], 20 ); + add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_legacy_assets' ), 20 );
📜 Review details
Configuration used: .coderabbit.yml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (6)
plugins/woocommerce/changelog/60223-fix-remove-legacy-scripts-loading(1 hunks)plugins/woocommerce/includes/class-wc-frontend-scripts.php(1 hunks)plugins/woocommerce/src/Blocks/BlockTemplatesController.php(1 hunks)plugins/woocommerce/src/Blocks/BlockTypes/ClassicTemplate.php(3 hunks)plugins/woocommerce/src/Blocks/BlockTypes/ProductDetails.php(2 hunks)plugins/woocommerce/src/Blocks/BlockTypes/ProductImageGallery.php(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (4)
- plugins/woocommerce/changelog/60223-fix-remove-legacy-scripts-loading
- plugins/woocommerce/includes/class-wc-frontend-scripts.php
- plugins/woocommerce/src/Blocks/BlockTypes/ProductDetails.php
- plugins/woocommerce/src/Blocks/BlockTypes/ClassicTemplate.php
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{php,js,jsx,ts,tsx}
📄 CodeRabbit Inference Engine (.cursor/rules/code-quality.mdc)
**/*.{php,js,jsx,ts,tsx}: Guard against unexpected inputs
Sanitize and validate any potentially dangerous inputs
Ensure code is backwards compatible
Write code that is readable and intuitive
Ensure code has unit or E2E tests where applicable
Files:
plugins/woocommerce/src/Blocks/BlockTypes/ProductImageGallery.phpplugins/woocommerce/src/Blocks/BlockTemplatesController.php
**/*.{php,js,ts,jsx,tsx}
⚙️ CodeRabbit Configuration File
**/*.{php,js,ts,jsx,tsx}: Don't trust that extension developers will follow the best practices, make sure the code:
- Guards against unexpected inputs.
- Sanitizes and validates any potentially dangerous inputs.
- Is backwards compatible.
- Is readable and intuitive.
- Has unit or E2E tests where applicable.
Files:
plugins/woocommerce/src/Blocks/BlockTypes/ProductImageGallery.phpplugins/woocommerce/src/Blocks/BlockTemplatesController.php
🧠 Learnings (14)
📓 Common learnings
Learnt from: ralucaStan
PR: woocommerce/woocommerce#58782
File: plugins/woocommerce/client/blocks/assets/js/base/utils/render-frontend.tsx:0-0
Timestamp: 2025-06-16T16:12:12.148Z
Learning: For WooCommerce checkout blocks, lazy loading was removed in favor of direct imports to prevent sequential "popping" effects during component loading. This approach prioritizes user experience over code splitting, with minimal bundle size impact and improved performance (1.7s to 1.1s speed score improvement). The checkout flow benefits from having all components load together rather than incrementally.
Learnt from: samueljseay
PR: woocommerce/woocommerce#58716
File: plugins/woocommerce/client/blocks/assets/js/blocks/mini-cart/iapi-frontend.ts:83-101
Timestamp: 2025-06-17T07:07:53.443Z
Learning: In WooCommerce blocks, when porting existing code patterns that have known issues (like parseInt truncating decimal money values), maintain consistency with existing implementation rather than making isolated fixes. The preference is for systematic refactoring approaches (like broader Dinero adoption) over piecemeal changes.
Learnt from: jorgeatorres
PR: woocommerce/woocommerce#59675
File: .github/workflows/release-bump-as-requirement.yml:48-65
Timestamp: 2025-07-15T15:39:21.856Z
Learning: In WooCommerce core repository, changelog entries for all PRs live in `plugins/woocommerce/changelog/` directory and are processed during releases, not at the repository root level.
Learnt from: lysyjan
PR: woocommerce/woocommerce#59632
File: packages/js/email-editor/src/layouts/flex-email.tsx:116-122
Timestamp: 2025-07-14T10:41:46.200Z
Learning: In WooCommerce projects, formatting suggestions should respect the project's Prettier configuration and linting rules. Changes that would break the lint job should be avoided, even if they appear to improve readability.
Learnt from: opr
PR: woocommerce/woocommerce#0
File: :0-0
Timestamp: 2025-06-20T17:38:16.565Z
Learning: WooCommerce legacy JavaScript files in plugins/woocommerce/client/legacy/js/ must use older JavaScript syntax and cannot use modern features like optional chaining (?.) due to browser compatibility requirements. Explicit null checking with && operators should be used instead.
Learnt from: NeosinneR
PR: woocommerce/woocommerce#0
File: :0-0
Timestamp: 2025-06-26T14:25:08.421Z
Learning: In WooCommerce transactional emails, product images have historically had display issues due to lazy loading attributes being applied, which email clients cannot process since they don't execute JavaScript. This issue existed in both old and new email templates, but became more visible with the new email template system. The fix involves preventing lazy loading on attachment images specifically during email generation by adding skip classes and data attributes.
Learnt from: Aljullu
PR: woocommerce/woocommerce#58809
File: plugins/woocommerce/src/Blocks/BlockTypes/ProductButton.php:222-225
Timestamp: 2025-06-13T17:11:13.732Z
Learning: In `plugins/woocommerce/src/Blocks/BlockTypes/ProductButton.php`, the team intentionally relies on toggling the `disabled` CSS class (via `data-wp-class--disabled`) instead of binding the `disabled` attribute, to mirror the behavior of the classic WooCommerce template.
Learnt from: Aljullu
PR: woocommerce/woocommerce#59370
File: plugins/woocommerce/client/blocks/assets/js/blocks/product-gallery/style.scss:236-243
Timestamp: 2025-07-03T10:09:20.635Z
Learning: In WooCommerce blocks CSS, prefer using standard CSS properties like `scrollbar-width` over vendor-specific prefixes when the standard property has good browser support. As of late 2024, `scrollbar-width` is widely supported across all major browsers and doesn't require WebKit-specific workarounds.
Learnt from: dinhtungdu
PR: woocommerce/woocommerce#59900
File: plugins/woocommerce/client/blocks/assets/js/blocks/product-filters/inner-blocks/attribute-filter/inspector.tsx:0-0
Timestamp: 2025-07-24T05:37:00.907Z
Learning: The DisplayStyleSwitcher component in plugins/woocommerce/client/blocks/assets/js/blocks/product-filters/components/display-style-switcher/index.tsx has been updated so that its onChange prop accepts only a string type (not string | number | undefined), eliminating the need for type assertions when using this component.
Learnt from: samueljseay
PR: woocommerce/woocommerce#59051
File: plugins/woocommerce/client/blocks/assets/js/blocks/mini-cart/mini-cart-contents/inner-blocks/mini-cart-footer-block/index.tsx:66-70
Timestamp: 2025-06-23T05:47:52.696Z
Learning: For WooCommerce mini-cart blocks in plugins/woocommerce/client/blocks/assets/js/blocks/mini-cart/, the standardized conditional pattern for experimental features should be `if ( isExperimentalMiniCartEnabled() ) { blockSettings.save = () => <InnerBlocks.Content />; }` - defaulting to the traditional Save component and only overriding when the experimental feature is enabled.
Learnt from: ralucaStan
PR: woocommerce/woocommerce#58782
File: plugins/woocommerce/client/blocks/assets/js/base/components/cart-checkout/product-details/style.scss:21-26
Timestamp: 2025-06-13T15:24:45.923Z
Learning: In WooCommerce blocks, bold styling for `.wc-block-components-product-details__name` should be scoped only to the Cart block (`.wc-block-cart__main`); on the Checkout block, product names are not bold because prices are highlighted instead.
Learnt from: nerrad
PR: woocommerce/woocommerce#60176
File: plugins/woocommerce/client/legacy/css/admin.scss:9088-9105
Timestamp: 2025-08-04T00:21:51.440Z
Learning: WooCommerce is currently in the midst of an admin redesign project, so temporary/short-term CSS solutions for admin pages are preferred over long-term refactoring when addressing immediate needs.
📚 Learning: in `plugins/woocommerce/src/blocks/blocktypes/productbutton.php`, the team intentionally relies on t...
Learnt from: Aljullu
PR: woocommerce/woocommerce#58809
File: plugins/woocommerce/src/Blocks/BlockTypes/ProductButton.php:222-225
Timestamp: 2025-06-13T17:11:13.732Z
Learning: In `plugins/woocommerce/src/Blocks/BlockTypes/ProductButton.php`, the team intentionally relies on toggling the `disabled` CSS class (via `data-wp-class--disabled`) instead of binding the `disabled` attribute, to mirror the behavior of the classic WooCommerce template.
Applied to files:
plugins/woocommerce/src/Blocks/BlockTypes/ProductImageGallery.phpplugins/woocommerce/src/Blocks/BlockTemplatesController.php
📚 Learning: the displaystyleswitcher component in plugins/woocommerce/client/blocks/assets/js/blocks/product-fil...
Learnt from: dinhtungdu
PR: woocommerce/woocommerce#59900
File: plugins/woocommerce/client/blocks/assets/js/blocks/product-filters/inner-blocks/attribute-filter/inspector.tsx:0-0
Timestamp: 2025-07-24T05:37:00.907Z
Learning: The DisplayStyleSwitcher component in plugins/woocommerce/client/blocks/assets/js/blocks/product-filters/components/display-style-switcher/index.tsx has been updated so that its onChange prop accepts only a string type (not string | number | undefined), eliminating the need for type assertions when using this component.
Applied to files:
plugins/woocommerce/src/Blocks/BlockTypes/ProductImageGallery.php
📚 Learning: in wordpress blocks, when there's a styling mismatch between editor and frontend, check if the php r...
Learnt from: gigitux
PR: woocommerce/woocommerce#58902
File: plugins/woocommerce/client/blocks/assets/js/blocks/product-specifications/edit.tsx:205-206
Timestamp: 2025-06-17T12:40:54.118Z
Learning: In WordPress blocks, when there's a styling mismatch between editor and frontend, check if the PHP renderer (like in `ProductSpecifications.php`) adds specific classes to the output. If so, add those same classes to the `useBlockProps` className in the editor component (like in `edit.tsx`) to ensure consistent styling. For example, adding `wp-block-table` class to both frontend and editor ensures core table styles and theme customizations apply consistently.
Applied to files:
plugins/woocommerce/src/Blocks/BlockTypes/ProductImageGallery.phpplugins/woocommerce/src/Blocks/BlockTemplatesController.php
📚 Learning: woocommerce legacy javascript files in plugins/woocommerce/client/legacy/js/ must use older javascri...
Learnt from: opr
PR: woocommerce/woocommerce#0
File: :0-0
Timestamp: 2025-06-20T17:38:16.565Z
Learning: WooCommerce legacy JavaScript files in plugins/woocommerce/client/legacy/js/ must use older JavaScript syntax and cannot use modern features like optional chaining (?.) due to browser compatibility requirements. Explicit null checking with && operators should be used instead.
Applied to files:
plugins/woocommerce/src/Blocks/BlockTypes/ProductImageGallery.phpplugins/woocommerce/src/Blocks/BlockTemplatesController.php
📚 Learning: in woocommerce transactional emails, product images have historically had display issues due to lazy...
Learnt from: NeosinneR
PR: woocommerce/woocommerce#0
File: :0-0
Timestamp: 2025-06-26T14:25:08.421Z
Learning: In WooCommerce transactional emails, product images have historically had display issues due to lazy loading attributes being applied, which email clients cannot process since they don't execute JavaScript. This issue existed in both old and new email templates, but became more visible with the new email template system. The fix involves preventing lazy loading on attachment images specifically during email generation by adding skip classes and data attributes.
Applied to files:
plugins/woocommerce/src/Blocks/BlockTypes/ProductImageGallery.phpplugins/woocommerce/src/Blocks/BlockTemplatesController.php
📚 Learning: in woocommerce blocks, when porting existing code patterns that have known issues (like parseint tru...
Learnt from: samueljseay
PR: woocommerce/woocommerce#58716
File: plugins/woocommerce/client/blocks/assets/js/blocks/mini-cart/iapi-frontend.ts:83-101
Timestamp: 2025-06-17T07:07:53.443Z
Learning: In WooCommerce blocks, when porting existing code patterns that have known issues (like parseInt truncating decimal money values), maintain consistency with existing implementation rather than making isolated fixes. The preference is for systematic refactoring approaches (like broader Dinero adoption) over piecemeal changes.
Applied to files:
plugins/woocommerce/src/Blocks/BlockTypes/ProductImageGallery.phpplugins/woocommerce/src/Blocks/BlockTemplatesController.php
📚 Learning: woocommerce block templates have a predictable structure where each block has one top-level div with...
Learnt from: samueljseay
PR: woocommerce/woocommerce#59142
File: plugins/woocommerce/src/Blocks/BlockTypes/MiniCart.php:594-602
Timestamp: 2025-06-25T06:51:41.381Z
Learning: WooCommerce block templates have a predictable structure where each block has one top-level div with wp-block-woocommerce- class containing arbitrary nested content that should be preserved.
Applied to files:
plugins/woocommerce/src/Blocks/BlockTypes/ProductImageGallery.phpplugins/woocommerce/src/Blocks/BlockTemplatesController.php
📚 Learning: the core/spacer block in the woocommerce email editor intentionally does not have a dedicated render...
Learnt from: lysyjan
PR: woocommerce/woocommerce#59070
File: packages/php/email-editor/src/Integrations/Core/class-initializer.php:103-141
Timestamp: 2025-06-23T16:55:58.246Z
Learning: The core/spacer block in the WooCommerce email editor intentionally does not have a dedicated renderer class and is handled by the fallback renderer instead of having an explicit render_email_callback assigned in the switch statement.
Applied to files:
plugins/woocommerce/src/Blocks/BlockTypes/ProductImageGallery.php
📚 Learning: in woocommerce blocks, bold styling for `.wc-block-components-product-details__name` should be scope...
Learnt from: ralucaStan
PR: woocommerce/woocommerce#58782
File: plugins/woocommerce/client/blocks/assets/js/base/components/cart-checkout/product-details/style.scss:21-26
Timestamp: 2025-06-13T15:24:45.923Z
Learning: In WooCommerce blocks, bold styling for `.wc-block-components-product-details__name` should be scoped only to the Cart block (`.wc-block-cart__main`); on the Checkout block, product names are not bold because prices are highlighted instead.
Applied to files:
plugins/woocommerce/src/Blocks/BlockTypes/ProductImageGallery.phpplugins/woocommerce/src/Blocks/BlockTemplatesController.php
📚 Learning: for woocommerce checkout blocks, lazy loading was removed in favor of direct imports to prevent sequ...
Learnt from: ralucaStan
PR: woocommerce/woocommerce#58782
File: plugins/woocommerce/client/blocks/assets/js/base/utils/render-frontend.tsx:0-0
Timestamp: 2025-06-16T16:12:12.148Z
Learning: For WooCommerce checkout blocks, lazy loading was removed in favor of direct imports to prevent sequential "popping" effects during component loading. This approach prioritizes user experience over code splitting, with minimal bundle size impact and improved performance (1.7s to 1.1s speed score improvement). The checkout flow benefits from having all components load together rather than incrementally.
Applied to files:
plugins/woocommerce/src/Blocks/BlockTemplatesController.php
📚 Learning: for woocommerce mini-cart blocks in plugins/woocommerce/client/blocks/assets/js/blocks/mini-cart/, t...
Learnt from: samueljseay
PR: woocommerce/woocommerce#59051
File: plugins/woocommerce/client/blocks/assets/js/blocks/mini-cart/mini-cart-contents/inner-blocks/mini-cart-footer-block/index.tsx:66-70
Timestamp: 2025-06-23T05:47:52.696Z
Learning: For WooCommerce mini-cart blocks in plugins/woocommerce/client/blocks/assets/js/blocks/mini-cart/, the standardized conditional pattern for experimental features should be `if ( isExperimentalMiniCartEnabled() ) { blockSettings.save = () => <InnerBlocks.Content />; }` - defaulting to the traditional Save component and only overriding when the experimental feature is enabled.
Applied to files:
plugins/woocommerce/src/Blocks/BlockTemplatesController.php
📚 Learning: in woocommerce's wc_delete_product_transients function, the context check includes both $is_admin_pa...
Learnt from: mreishus
PR: woocommerce/woocommerce#58817
File: plugins/woocommerce/includes/wc-product-functions.php:140-140
Timestamp: 2025-06-13T23:52:46.221Z
Learning: In WooCommerce's wc_delete_product_transients function, the context check includes both $is_admin_page (for regular admin screens) and $is_privileged_ajax (for AJAX requests from users with edit_products capability), ensuring that legitimate admin AJAX operations like product imports/exports can still delete transients.
Applied to files:
plugins/woocommerce/src/Blocks/BlockTemplatesController.php
📚 Learning: on specific woocommerce admin pages like advanced keys, advanced webhooks, and extensions pages, the...
Learnt from: nerrad
PR: woocommerce/woocommerce#60176
File: plugins/woocommerce/client/legacy/css/admin.scss:9108-9115
Timestamp: 2025-08-04T00:21:08.386Z
Learning: On specific WooCommerce admin pages like Advanced Keys, Advanced Webhooks, and Extensions pages, the screen meta links (#screen-meta-links) are intentionally hidden with display:none because the Help tab and Screen Options functionality is not needed or relevant for these particular routes, making complete DOM removal appropriate rather than just visual hiding.
Applied to files:
plugins/woocommerce/src/Blocks/BlockTemplatesController.php
🔇 Additional comments (3)
plugins/woocommerce/src/Blocks/BlockTemplatesController.php (2)
33-34: LGTM! Proper integration of legacy script dequeuing.The action hook is correctly added with priority 20, which aligns with the enqueue priority used in legacy blocks, ensuring proper execution order.
36-40: LGTM! Clean and secure legacy script management.The implementation correctly:
- Uses the safe
is_product()conditional check- Targets the specific
wc-single-productscript handle- Follows the dequeue-then-selective-enqueue pattern for optimization
This approach allows legacy blocks to re-enqueue scripts as needed while preventing unnecessary loading on block themes.
plugins/woocommerce/src/Blocks/BlockTypes/ProductImageGallery.php (1)
33-46: LGTM! Proper conditional asset enqueuing.The implementation correctly:
- Calls the parent
enqueue_assets()method to maintain inheritance- Uses
is_product()for safe conditional logic- Sets priority 20 to execute after the global dequeue in
BlockTemplatesController- Follows the established pattern for legacy asset management
|
@kmanijak Thank you for the review. In the latest commits, I chose to refactor my approach. I believe we should avoid modifying the Because of this significant change, could you review it once more? |
kmanijak
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.
I double checked the scenarios and all works fine still. I also checked the other classic templates (I appreciate the is_product() check!) so they don't load unnecessary dependencies.
I left one minor comment but it's not super crucial so approving again!
| if ( is_product() ) { | ||
| add_action( 'wp_enqueue_scripts', [ $this, 'enqueue_legacy_assets' ], 20 ); | ||
| } |
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.
In this case, I think we can skip the is_product() check 🤔 Check makes sense in Classic Template but if Product Image Gallery is used, then we can safely assume the dependencies are needed. WDYT?
|
Blocked by #60213 |
|
woocommerce/plugins/woocommerce/src/Blocks/BlockTypes/ClassicTemplate.php Lines 101 to 126 in 1017bd1
@dinhtungdu Excuse me, but why Why Why enqueue Photoswipe when I have Does opting out of these features work differently now? |
|
@ktmn, the support behavior for classic themes remains unchanged. This effort aims to optimize frontend performance for block themes. Previously, we always added gallery support for block themes, regardless of whether they used the classic template block. As a result, the gallery scripts are always loaded for block themes unless the active theme removes the gallery support. This pull request changes that by moving the script loading to the classic template block and the gallery block. We assume that users utilizing these blocks will also use the classic gallery. We may have overlooked certain use cases, especially if you are removing gallery support while using the classic template block. We will investigate how to support disabling the gallery script when using the Classic Template block. We can't use theme supports here, as we only want to enqueue the gallery and single product scripts when the legacy blocks are in use. |
I'm using a block theme though, just not with any WC blocks (except for Not sure what that qualifies as, a "classic theme"? I disabled all the functionality I don't need via the |
|
You're using a block theme with the Classic Template ( |
Submission Review Guidelines
Changes proposed in this Pull Request
This PR limits loading legacy single product scripts only for legacy blocks.
Script Loading Duplication:
The enqueue logic is intentionally duplicated across
ClassicTemplate.phpandProductImageGallery.phprather than abstracted into a shared utility to maintain independence between legacy blocks, allowing each to be deprecated separately without creating cross-dependencies.Legacy Script Bundle:
We keep the entire
single-product.jsfile rather than splitting it into modules (gallery, zoom, tabs, reviews) to maintain backward compatibility without introducing breaking changes. The file size also makes splitting not worth the effort.How to test the changes in this Pull Request
Using the WooCommerce Testing Instructions Guide, include your detailed testing instructions:
single-product.jsand its dependencies loaded.single-product.jsand its dependencies loaded.single-product.jsand its dependencies loaded.single-product.jsloaded on the frontend without gallery dependencies.single-product.jsand its gallery dependencies aren't loaded on the frontend.Changelog entry
Changelog Entry Details
Significance
Type
Message
Limit loading legacy single product scripts only for legacy blocks