-
Notifications
You must be signed in to change notification settings - Fork 850
Likes: add minified build for CSS #46750
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
base: trunk
Are you sure you want to change the base?
Conversation
Add the likes module CSS to the webpack CSS config so it gets minified for production. Update both likes.php and the Like block to use Assets::get_file_url_for_environment to serve the minified version when SCRIPT_DEBUG is false. Follows the pattern established for subscriptions in #44546.
|
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
Interested in more tips and information?
|
|
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 🤖 Follow this PR Review Process:
If you have questions about anything, reach out in #jetpack-developers for guidance! Jetpack plugin: The Jetpack plugin has different release cadences depending on the platform:
If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. |
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.
Pull request overview
This PR wires the Likes module CSS into the CSS webpack pipeline so it can be minified and then enqueued conditionally based on the environment, similar to the recent Subscriptions work. It also updates the Likes module and Like block to use the new minified asset and adds a corresponding changelog entry.
Changes:
- Add
modules/likes/style.cssto the CSS webpack config (weirdRtlEntries) to build_inc/build/likes/style.min.cssand RTL variants. - Update the Likes module (
modules/likes.php) to enqueue the minified Likes stylesheet viaAssets::get_file_url_for_environment()and use the same helper for the queuehandler script. - Update the Like block (
extensions/blocks/like/like.php) to use the new minified Likes stylesheet URL and adjust its handling of style path metadata, and add a Jetpack changelog entry describing the enhancement.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
projects/plugins/jetpack/tools/webpack.config.css.js |
Adds a weirdRtlEntries entry so modules/likes/style.css is built to _inc/build/likes/style.min.css (and RTL) and picked up by the existing CSS build pipeline. |
projects/plugins/jetpack/modules/likes.php |
Switches frontend Likes CSS and JS enqueues to use Assets::get_file_url_for_environment() and the new _inc/build/likes/style.min.css asset, but currently misuses the CSS URL as the path metadata. |
projects/plugins/jetpack/extensions/blocks/like/like.php |
Updates the Like block to use the new minified Likes CSS/JS URLs in the non-WPCOM branch, but also sets the path metadata to a URL instead of a filesystem path. |
projects/plugins/jetpack/changelog/update-minify-likes-css |
Adds a changelog entry summarizing the new minified Likes CSS build and enqueue behavior, following the existing changelog conventions. |
| 'modules/likes/style.css' | ||
| ); | ||
| wp_enqueue_style( 'jetpack_likes', $style_url, array(), JETPACK__VERSION ); | ||
| wp_style_add_data( 'jetpack_likes', 'path', $style_url ); |
Copilot
AI
Jan 23, 2026
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.
wp_style_add_data( 'jetpack_likes', 'path', $style_url ); is passing a URL as the path value, but WordPress expects this metadata to be a filesystem path (used for inlining via wp_maybe_inline_styles()), and elsewhere in the codebase we consistently pass real paths via plugin_dir_path( __FILE__ ) or similar. This will at best cause unnecessary file-fetching over HTTP (and can fail outright when URL wrappers are disabled), and it’s also a regression from the previous implementation that used plugin_dir_path( __FILE__ ) . 'likes/style.css'. Please change this to pass an actual filesystem path corresponding to the selected CSS file (minified vs non-minified depending on SCRIPT_DEBUG), while keeping $style_url as the enqueued URL.
| wp_style_add_data( 'jetpack_likes', 'path', $style_url ); | |
| $style_path = plugin_dir_path( JETPACK__PLUGIN_FILE ) . ( | |
| ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) | |
| ? 'modules/likes/style.css' | |
| : '_inc/build/likes/style.min.css' | |
| ); | |
| wp_style_add_data( 'jetpack_likes', 'path', $style_path ); |
| '_inc/build/likes/style.min.css', | ||
| 'modules/likes/style.css' | ||
| ); | ||
| $style_path = $style_url; |
Copilot
AI
Jan 23, 2026
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 the non-WPCOM branch, $style_path is set to $style_url, so when we later call wp_style_add_data( 'jetpack_likes', 'path', $style_path ); the path metadata is a URL instead of a filesystem path. Core expects a real path here for inlining (see usage in other modules where we use plugin_dir_path( __FILE__ )), so this can break or degrade CSS inlining and is a regression from the previous implementation that used a true file path. Please keep $style_url as the URL for wp_enqueue_style(), but compute $style_path as the corresponding filesystem path (minified vs non-minified depending on environment), similar to how the WPCOM branch uses WP_CONTENT_DIR.
| $style_path = $style_url; | |
| $style_path = JETPACK__PLUGIN_DIR . ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? 'modules/likes/style.css' : '_inc/build/likes/style.min.css' ); |
The 'path' metadata for wp_style_add_data expects a filesystem path for CSS inlining, not a URL. Compute the correct path based on SCRIPT_DEBUG to point to either the minified or non-minified file.
Use the existing filter for consistency with the rest of the codebase.
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.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
Code Coverage SummaryCoverage changed in 2 files.
Full summary · PHP report · JS report Coverage check overridden by
I don't care about code coverage for this PR
|
See #46671
Proposed changes:
Minify the Likes stylesheet and use it in self-hosted environments.
Other information:
Jetpack product discussion
Does this pull request change what data or activity we track or use?
Testing instructions:
wp-config.phpfile, ensure thatSCRIPT_DEBUGis set to false.wp-config.phpto setSCRIPT_DEBUGto true.