Skip to content

Commit

Permalink
Gutenberg: Dequeue editor assets when they aren't in use (#34268)
Browse files Browse the repository at this point in the history
* Gutenberg: Dequeue editor assets when they aren't in use

* Add changelog

* Fix whitespace
  • Loading branch information
tyxla authored Nov 27, 2023
1 parent 8ea9937 commit 4c19578
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: enhancement

Gutenberg: Dequeue editor assets when they aren't in use
12 changes: 12 additions & 0 deletions projects/plugins/jetpack/class.jetpack-gutenberg.php
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,18 @@ public static function enqueue_block_editor_assets() {
return;
}

/**
* This can be called multiple times per page load in the admin, during the `enqueue_block_assets` action.
* These assets are necessary for the admin for editing but are not necessary for each pattern preview.
* Therefore we dequeue them, so they don't load for each pattern preview iframe.
*/
if ( ! wp_should_load_block_editor_scripts_and_styles() ) {
wp_dequeue_script( 'jp-tracks' );
wp_dequeue_script( 'jetpack-blocks-editor' );

return;
}

$status = new Status();

// Required for Analytics. See _inc/lib/admin-pages/class.jetpack-admin-page.php.
Expand Down

0 comments on commit 4c19578

Please sign in to comment.