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

[Boost] Fix minify paths on sites in a subdir. #30893

Merged
merged 3 commits into from
May 29, 2023
Merged

Conversation

thingalon
Copy link
Member

Related: pedxs5-eK-p2#comment-114

When minifying and concatenating css on a site in a subdirectory, URLs weren't being properly interpreted. URLs like /wp-includes/* are relative to WordPress' home URL, and were being treated as relative to the root path of the domain.

#30863 went some way towards fixing that, but only fixed it for JS URLs. This PR updates the fix to apply to both JS and CSS URLs.

Proposed changes:

  • Ensure that enqueued script and css URLs are treated as relative to WordPress home

Other information:

  • Have you written new tests for your changes, if applicable?
  • Have you checked the E2E test CI results, and verified that your changes do not break them?
  • Have you tested your changes on WordPress.com, if applicable (if so, you'll see a generated comment below with a script to run)?

Jetpack product discussion

n/a

Does this pull request change what data or activity we track or use?

no

Testing instructions:

  • Use a WordPress site on a subdirectory on any domain.
  • Ensure that CSS and JS are properly minfied and concatenated.

@thingalon thingalon requested review from brandonpayton, dilirity and a team May 24, 2023 09:05
@thingalon thingalon self-assigned this May 24, 2023
@thingalon thingalon marked this pull request as ready for review May 24, 2023 09:05
@github-actions github-actions bot added [Plugin] Boost A feature to speed up the site and improve performance. [Status] In Progress labels May 24, 2023
@github-actions
Copy link
Contributor

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • ✅ All commits were linted before commit.
  • ✅ Add a "[Status]" label (In Progress, Needs Team Review, ...).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖


The e2e test report can be found here. Please note that it can take a few minutes after the e2e tests checks are complete for the report to be available.


Once your PR is ready for review, check one last time that all required checks (other than "Required review") appearing at the bottom of this PR are passing or skipped.
Then, add the "[Status] Needs Team review" label and ask someone from your team review the code.
Once you’ve done so, switch to the "[Status] Needs Review" label; someone from Jetpack Crew will then review this PR and merge it to be included in the next Jetpack release.


Boost plugin:

  • Next scheduled release: June 6, 2023.
  • Scheduled code freeze: May 29, 2023.

1 similar comment
@github-actions
Copy link
Contributor

github-actions bot commented May 24, 2023

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • ✅ All commits were linted before commit.
  • ✅ Add a "[Status]" label (In Progress, Needs Team Review, ...).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖


The e2e test report can be found here. Please note that it can take a few minutes after the e2e tests checks are complete for the report to be available.


Once your PR is ready for review, check one last time that all required checks (other than "Required review") appearing at the bottom of this PR are passing or skipped.
Then, add the "[Status] Needs Team review" label and ask someone from your team review the code.
Once you’ve done so, switch to the "[Status] Needs Review" label; someone from Jetpack Crew will then review this PR and merge it to be included in the next Jetpack release.


Boost plugin:

  • Next scheduled release: June 6, 2023.
  • Scheduled code freeze: May 29, 2023.

dilirity
dilirity previously approved these changes May 25, 2023
Copy link
Member

@dilirity dilirity left a comment

Choose a reason for hiding this comment

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

Good catch! Thanks for fixing this. Code looks great.

:shipit:

* Note: this method uses home_url, so should only be used plugin-side when
* generating concatenated URLs.
*/
function enqueued_to_absolute_url( $url ) {
Copy link
Member

Choose a reason for hiding this comment

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

Hi @thingalon, it seems like it would be good to prefix this function name with jetpack_boost_ to reduce the possibility of naming collisions.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point, thank you. Fixed in e0b3f35.

Copy link
Member

@dilirity dilirity May 26, 2023

Choose a reason for hiding this comment

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

🤦🏻 I missed that. I thought they were namespaced.

Copy link
Member

Choose a reason for hiding this comment

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

It's an understandable assumption. :) Namespaces seem common in Jetpack, but the team that created the bits from Page Optimize heavily favors function prefixing over dealing with namespaces.

Copy link
Member

@brandonpayton brandonpayton left a comment

Choose a reason for hiding this comment

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

I haven't tested this directly, but these changes look reasonable to me.

@thingalon thingalon merged commit 8f638ce into trunk May 29, 2023
@thingalon thingalon deleted the fix/minify-css-urls branch May 29, 2023 06:09
thingalon added a commit that referenced this pull request May 29, 2023
* Properly take home_url into account to catch subdir paths

* changelog

* Prepend method with jetpack_boost_

---------

Co-authored-by: Mark George <thingalon@gmail.com>
@thingalon
Copy link
Member Author

Cherry-picked to 1.9.0 in fb26b14

haqadn added a commit that referenced this pull request Jun 1, 2023
* Update readme and changelogs for Boost 1.9.0-beta

* Updated package versions for automattic/jetpack-boost

* [not verified] Boost/add minify to pricing (#30711)

* Add minify and concat to pricing tables

* changelog

---------

Co-authored-by: Mark George <thingalon@gmail.com>

* [not verified] Boost: Fix UI issues (#30751)

* Fix showing exclude text when no value is empty

* Fix bottom tooltip showing below footer on getting started page

* Update tooltip position in pricing table component to be configurable

* Update tooltip positions in left column on getting started page

* Fix score text capitalization

* Add changelogs

* [not verified] Boost: Update Minify to use old Page Optimize file functions (#30829)

* Fix concat initializing despite file system being unavailable

* add changelog

* Ignore file_* function usage for phpcs

* Update changelog

* Revert changes to minify setup helper

* [not verified] Boost: Fix Minify concat not working when WP is running from a subdirectory on the server (#30863)

* Fix issues with wp instances in subdirectory urls

* Add changelog

* Boost: Make Minify concat concat service independent of WordPress (#30825)

* Attempt to remove WordPress dependencies from Minify service

* add changelog

* Fix concat initializing despite file system being unavailable

* add changelog

* Add missing cssmin library

* Ignore file_* function usage for phpcs

* Update changelog

* Revert changes to minify setup helper

* Attempt to remove WordPress dependencies from Minify service

* Add changelog

* Add missing cssmin library

* Clean up old file system references

* Fix issues with wp instances in subdirectory urls

* Fix issues with wp instances in subdirectory urls

* Add changelog

* Remove comments

* Improve code readability

* Make linter happy

* changelog

---------

Co-authored-by: Mark George <thingalon@gmail.com>

* [not verified] [Boost] Fix minify paths on sites in a subdir. (#30893)

* Properly take home_url into account to catch subdir paths

* changelog

* Prepend method with jetpack_boost_

---------

Co-authored-by: Mark George <thingalon@gmail.com>

* [not verified] [Boost] Remove invalid apply_filter on minified CSS (#31058)

* Do not call style_loader_tag with an array of handles

* changelog

---------

Co-authored-by: Mark George <thingalon@gmail.com>

* [not verified] [Boost] Avoid double-prefixing url() values in minified CSS (#31059)

* Prevent double-prefixing subdirectories

* changelog

---------

Co-authored-by: Mark George <thingalon@gmail.com>

* Boost/update readme (#31065)

* Update screenshots and readme

* changelog

* Remove out-dated paragraph

---------

Co-authored-by: Mark George <thingalon@gmail.com>

* Update readme, changelogs

* Update version numbers

* fix changelog link

* [not verified] Updated automattic/jetpack-boost version to 1.9.1

* [not verified] Updated package versions for automattic/jetpack-boost

* [not verified] Update readme and changelog

* Set stable tag to 1.9.0

* Fixup project versions

* Fix changelog and project versions

* Fix boost composer

* Composer update

* Composer update from within docker container for php 8.0

---------

Co-authored-by: thingalon <mark@thingalon.com>
Co-authored-by: Mark George <thingalon@gmail.com>
Co-authored-by: Peter Petrov <peter.petrov89@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Plugin] Boost A feature to speed up the site and improve performance.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants