Skip to content
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

Fix google-product-category-fields-loads.js loading on every page. #2331

Merged

Conversation

rawdreeg
Copy link
Contributor

Changes proposed in this Pull Request:

Closes #1949 .

admin/google-product-category-fields.js currently loads on all admin pages. This PR restricts it to the product_cat and edit-product_cat screens where it's needed for the google product category fields.

Issue #1949 makes other recommendations such as adding an async/defer attribute and moving the script to the footer, which I decided against because it would mean delaying the init execution which impacts UX:

https://github.com/woocommerce/facebook-for-woocommerce/blob/5156a45c02672057476573f0b79c58084f20f10f/includes/Admin/Google_Product_Category_Field.php#L30-L38

I also decided not to make changes to infobanner assets as we still need to evaluate whether this is currently needed. See #1981

  • [ x] Do the changed files pass phpcs checks? Please remove phpcs:ignore comments in changed files and fix any issues, or delete if not practical.

Detailed test instructions:

  1. Check out this branch.
  2. Navigate to the admin dashboard, confirm google-product-category-fields-loads.js does not load on all page
  3. Navigate to Admin -> Product -> Categories, confirm the google fields work as expected

Changelog entry

Fix - Ensure google-product-category-fields-loads.js loads only on the product category screens.

@github-actions github-actions bot added changelog: fix Took care of something that wasn't working. type: bug The issue is a confirmed bug. labels Oct 19, 2022
@rawdreeg rawdreeg requested a review from a team October 19, 2022 16:35
@message-dimke
Copy link
Contributor

message-dimke commented Oct 19, 2022

Hey, @rawdreeg !

Thanks for the PR, I can confirm google-product-category-fields.js loads at every Admin page before the code changes, but I can also confirm few more places than just Product > Category which require the file.

Edit_product_“New_product”_‹_WordPress-Facebook_—_WordPress

Facebook_for_WooCommerce_‹_WordPress-Facebook_—_WordPress

There are maybe more, these are two were on my memory.

@rawdreeg
Copy link
Contributor Author

Thanks for catching this, @message-dimke. I have ensured the google-product-category-fields.js loads everywhere it's needed.

Screenshot 2022-10-20 at 07 16 57

Screenshot 2022-10-20 at 07 16 49

This is ready for another round of reviews :-)

Copy link
Contributor

@message-dimke message-dimke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks, @rawdreeg!

@rawdreeg rawdreeg merged commit a620aa0 into develop Oct 20, 2022
@rawdreeg rawdreeg deleted the fix/google-product-category-fields-loads-on-every-admin-page branch October 20, 2022 16:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog: fix Took care of something that wasn't working. type: bug The issue is a confirmed bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Assets performance suggestions + DB query optimisations
2 participants