-
Notifications
You must be signed in to change notification settings - Fork 818
Boost: Add notice if legacy concatenation files are used #41604
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
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
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. Follow this PR Review Process:
Still unsure? Reach out in #jetpack-developers for guidance! Boost plugin:
If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. |
Code Coverage SummaryCoverage changed in 3 files.
2 files are newly checked for coverage.
Full summary · PHP report · JS report Add label
I don't care about code coverage for this PR
|
…catenation-notice
- Refactor `useStaticMinification` hook to return more detailed query data - Update Minification modules to use new hook and add immediate 404 tester on activation - Modify module UI to conditionally show notices based on loading and enabled states - Add option to run 404 tester immediately during module activation
- Remove Minify_Notice_Entry and replace with a readonly option for static minification - Add new components for Minify CSS and JS modules - Introduce a LegacyMinifyNotice component for displaying static minification warning - Update performance history hooks to support static minification notice - Simplify index page by extracting minification modules into separate components
Code Coverage SummaryCoverage changed in 3 files.
3 files are newly checked for coverage.
Full summary · PHP report · JS report Coverage check overridden by
I don't care about code coverage for this PR
|
- Rename and update MinifyLegacyNotice component with more detailed information - Update data sync keys and hooks for legacy minify notice - Modify minify CSS and JS modules to use new legacy notice logic - Remove static-minification store and replace with minify store - Add support for dismissing legacy minify notice with analytics tracking
- Add namespace definition for Jetpack Boost data sync - Rename parameter in jetpack_boost_404_setup for clarity
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.
Overall looks good. I have a couple of nitpicks and noticed an issue.
The notice flashes for a moment when you enable any of the concat modules for the first time.
@@ -350,12 +356,12 @@ function jetpack_boost_minify_serve_concatenated() { | |||
* | |||
* @return void | |||
*/ | |||
function jetpack_boost_minify_activation() { | |||
function jetpack_boost_minify_activation( $run_tester_immediately = false ) { |
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.
Are there situations where we do not need to run 404 tester immediately on minify activation? If not, I think we should pass a boolean directly to the jetpack_boost_404_setup
function.
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.
We do run the 404 tester activation if we detect the plugin has been updated, and they have either Minify Module enabled.
jetpack/projects/plugins/boost/app/class-jetpack-boost.php
Lines 152 to 167 in 55c6ab8
public function handle_version_change() { | |
$version = get_option( 'jetpack_boost_version' ); | |
if ( $version === JETPACK_BOOST_VERSION ) { | |
return; | |
} | |
update_option( 'jetpack_boost_version', JETPACK_BOOST_VERSION ); | |
if ( jetpack_boost_minify_is_enabled() ) { | |
// We need to clear Minify scheduled events to ensure the latest scheduled jobs are only scheduled irrespective of scheduled arguments. | |
jetpack_boost_minify_clear_scheduled_events(); | |
jetpack_boost_minify_activation(); | |
} | |
} | |
Though I don't think there would be an issue with running the 404 tester itself immediately in this scenario either. So I'm updating the code to apply your feedback.
@@ -188,9 +188,15 @@ function jetpack_boost_page_optimize_remove_concat_base_prefix( $original_fs_pat | |||
/** | |||
* Schedule a cronjob for the 404 tester, if one isn't already scheduled. | |||
*/ | |||
function jetpack_boost_page_optimize_schedule_404_tester() { | |||
function jetpack_boost_page_optimize_schedule_404_tester( $run_immediately = false ) { |
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.
Perhaps we can skip the chain of boolean and run immediately always if no cron is scheduled?
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.
Good point, I've updated the PR to remove the chain of booleans, and in relation to this comment.
// Otherwise show it if the 404 tester determined it can't be used. | ||
return ! (bool) get_site_option( 'jetpack_boost_static_minification' ); |
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.
The flashing notice issue mentioned above is probably because of this. Before the 404 tester has a chance to run, the default value is false as the option doesn't exist yet.
As a result, when you enable a module, initially the notice will show. After it has a chance to fetch, it hides the notice again. I think something like the following might work:
// Otherwise show it if the 404 tester determined it can't be used. | |
return ! (bool) get_site_option( 'jetpack_boost_static_minification' ); | |
/* | |
* Until the 404 tester running, the option will not be created and it will return false. | |
* However, we don't want to show the notice before the tester has a chance to run. | |
* We only want to show the notice when the tester has already run and determined that | |
* it will use the fallback system. | |
*/ | |
return get_site_option( 'jetpack_boost_static_minification' ) !== ''; |
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.
Nice catch, I've updated the PR with something similar to your solution.
> | ||
<p> | ||
{ __( | ||
'You are using the legacy cache delivery method for concatenated files.', |
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 a bit unsure about this. But, maybe we don't want to call it legacy in a user-facing way? I think the notice should instead say something like: "You can improve the speed of concatenated files and reduce the load on WordPress." ... Learn More.
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.
You're right legacy may not be the correct word here, we also don't mention it's legacy in the documentation. I've updated the PR with that text, and Oxford comma.
- Remove immediate 404 tester parameter from activation functions - Update legacy notice to conditionally display based on static minification state - Simplify 404 tester scheduling logic - Modify legacy notice text to focus on performance improvement
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 think it's ready to merge. But, I have one tiny suggestion.
const [ query ] = useDataSync( 'jetpack_boost_ds', 'minify_legacy_notice', z.boolean() ); | ||
|
||
return query; |
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.
It's a nitpick but since we aren't using other properties, can we narrow it down to data? This will make it cleaner on the end it is being used.
const [ query ] = useDataSync( 'jetpack_boost_ds', 'minify_legacy_notice', z.boolean() ); | |
return query; | |
const [ query: { data } ] = useDataSync( 'jetpack_boost_ds', 'minify_legacy_notice', z.boolean() ); | |
return data; |
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.
We're using the refetch
function within the Minify components so the query object is needed unfortunately, e.g.
jetpack/projects/plugins/boost/app/assets/src/js/features/minify-js/minify-js.tsx
Line 22 in 866d7dd
onEnable={ showMinifyLegacy.refetch } |
Fixes 41675.
If the new static cache files introduced in #41056 are not being used by a server then notify the user so they can fix the problem.
Proposed changes:
Other information:
Jetpack product discussion
pc9hqz-3kc-p2
Does this pull request change what data or activity we track or use?
Testing instructions:
jetpack rebuild plugins/boost
to build everything.RewriteEngine Off
in it.JETPACK_BOOST_DISABLE_404_TESTER
within yourwp-config.php
.htaccess
tohtaccess
added previously.