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
Mailchimp: only load CSS when needed. #11128
Conversation
D23075-code. (newly created revision) |
This is automated check which relies on |
For others who may want to get rid of the stylesheet today, before that patch ships, you can use the following snippet: function jetpackcom_dequeue_mailchimp_style() {
wp_dequeue_style( 'jetpack-email-subscribe' );
wp_deregister_style( 'jetpack-email-subscribe' );
}
add_action( 'wp_enqueue_scripts', 'jetpackcom_dequeue_mailchimp_style' ); |
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 had some trouble replicating the issue in master. I think it was because I had not yet connected a Mailchimp account.
LGTM, though.
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 had some trouble reproducing the problem in master. I think it was because I had not yet connected a Mailchimp account.
Got it working and looks good to me.
- `wp_style_is` only accepts 'enqueued', 'registered', 'queue', 'to_do', and 'done'. Switch to using enqueued instead of enqueue. - The style was previously declared when the block was registered. It caused it to be enqueued on all pages of the site, even when the block or the shortcode are not in use. Since we enqueue the file manually ourselves inside parse_shortcode, we don't need to enqueue it anywhere else.
`wp_style_is` only accepts 'enqueued', 'registered', 'queue', 'to_do', and 'done'. Switch to using enqueued instead of enqueue.
4a5e47b
to
cf3cd6e
Compare
D23350-code. (newly created revision) |
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.
Managed to repro this time. Still looks good to me.
The phab diffs linked from this PR (D23075-code and D23350-code) seem to have only updated Simple Payments but not Mailchimp... |
Probably since Fusion wasn't syncing Mailchimp files when this PR was created. |
Changes proposed in this Pull Request:
This PR introduces 3 changes:
style
when registering the block. We don't need to declare it there since the style is actually enqueued manually inparse_shortcode
.wp_style_is
only accepts 'enqueued', 'registered', 'queue', 'to_do', and 'done'.jetpack.css
file that is automatically generated by Jetpack. This way we don't ever need to load the CSS file separately anymore.Testing instructions:
add_filter( 'jetpack_implode_frontend_css', '__return_false', 99 );
to your site.jetpack-email-subscribe
CSS stylesheet loaded anywhere.[jetpack-email-subscribe]
shortcode. You should see the stylesheet loaded there.define( 'JETPACK_BETA_BLOCKS', true );
to your site'swp-config.php
file.yarn build
jetpack-email-subscribe
styles inside thejetpack.css
file that is enqueued.Proposed changelog entry for your changes: