-
Notifications
You must be signed in to change notification settings - Fork 805
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
MU WPCOM: don't enqueue block scripts in the canvas iframe! #41055
base: trunk
Are you sure you want to change the base?
Conversation
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 🤖 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! Mu Wpcom plugin:
If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. Wpcomsh plugin:
If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. |
@@ -86,7 +86,7 @@ function () { | |||
); | |||
|
|||
add_action( | |||
is_admin() ? 'enqueue_block_assets' : 'enqueue_block_editor_assets', |
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 wonder what's the historic reason for this.
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.
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.
Also no other blocks are doing this (otherwise this PR wouldn't entirely remove the packages enqueued).
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.
Yes, I just migrated the code to this repo, and kept everything the same as before to avoid any regressions
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.
Oops...my memory was wrong, and I just followed the comment below. It seemed something was wrong but I forgot the reason.
jetpack/projects/plugins/jetpack/class.jetpack.php
Lines 632 to 641 in 5042902
/** | |
* We've switched from enqueue_block_editor_assets to enqueue_block_assets in WP-Admin because the assets with the former are loaded on the main site-editor.php. | |
* | |
* With the latter, the assets are now loaded in the SE iframe; the implementation is now faster because Gutenberg doesn't need to inject the assets in the iframe on client-side. | |
*/ | |
if ( is_admin() ) { | |
add_action( 'enqueue_block_assets', array( 'Jetpack_Gutenberg', 'enqueue_block_editor_assets' ) ); | |
} else { | |
add_action( 'enqueue_block_editor_assets', array( 'Jetpack_Gutenberg', 'enqueue_block_editor_assets' ) ); | |
} |
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.
This makes sense.
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.
Thanks for addressing this 🙂
Problem:
React and most block editor packages are currently loaded in both the main window and the editor canvas iframe. This should not happen. (Note that you don't need any blocks inserted.)
Additionally there's an error message from one of the scripts that's added in the iframe:
Proposed changes:
enqueue_block_assets
for some reason. This is wrong, since that hook is meant for assets to the block itself rather than assets to register the blocks. Instead,enqueue_block_editor_assets
should be used.Other information:
Jetpack product discussion
Does this pull request change what data or activity we track or use?
Testing instructions:
<head>
of the canvas.