-
Notifications
You must be signed in to change notification settings - Fork 839
Enable WordPress-controlled CSS loading for Instant Search #45694
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
Changes webpack configuration to disable automatic CSS injection and allow WordPress to control CSS loading via wp_enqueue_style, making Instant Search compatible with the WordPress Interactivity API. Changes: - Configure MiniCssExtractPlugin with static filenames (no contenthash) - Disable CSS runtime loading (runtime: false) - Disable MiniCssWithRtlPlugin (WordPress handles RTL) - Add css_path to Assets::register_script() for WordPress CSS enqueuing This ensures CSS loads in <head> before JavaScript hydration, preventing duplicate loading while maintaining proper cache busting through WordPress versioning. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
|
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! |
Code Coverage SummaryCoverage changed in 1 file.
|
Proposed changes:
This PR modifies the Instant Search build configuration to make it compatible with the WordPress Interactivity API by allowing WordPress to control CSS loading instead of webpack's automatic injection.
Changes:
runtime: false)css_pathparameter toAssets::register_script()to enqueue CSS via WordPressWhy these changes?
The WordPress Interactivity API requires CSS to be properly enqueued in the
<head>before JavaScript hydration occurs. Previously, webpack was dynamically injecting CSS when the async chunk loaded, which:Now CSS is:
jp-search.chunk-main-payload.css)?ver=<ver>)<head>before any JavaScript executesOther information:
Jetpack product discussion
p1753090979383509-slack-C02ME06LF
Does this pull request change what data or activity we track or use?
No, this PR only changes how CSS assets are loaded. No tracking or data collection changes.
Testing instructions:
Prerequisites
Testing Steps
cd projects/packages/search pnpm run build-instantls -la build/instant-search/*.cssjp-search.chunk-main-payload.cssjp-search.chunk-main-payload.rtl.css(No version hash in the filename itself)
Check that webpack doesn't include CSS loading runtime:
grep -c "miniCssF" build/instant-search/jp-search.jsShould return 0 (no CSS loading code)
Test in WordPress:
jp-search.chunk-main-payload.cssjp-search.chunk-main-payload.cssjp-search.chunk-main-payload.js) loads successfully