How to only enqueue block javascript on the frontend when its needed [duplicate]
To register scripts/styles conditionally if the page has a certain block you can follow the solution that @Will posted in the comments from a similar question. Copy/pasting with some modifications from that question: add_action( ‘enqueue_block_assets’, ‘myplugin_enqueue_if_block_is_present’ ); // Can only be loaded in the footer // add_action( ‘wp_enqueue_scripts’, ‘myplugin_enqueue_if_block_is_present’ ); // Can be loaded in … Read more