=' ); if ( $supports_defer ) { // Defer execution of @wordpress/interactivity package but continue loading in head. wp_script_add_data( 'wp-interactivity', 'strategy', 'defer' ); wp_script_add_data( 'wp-interactivity', 'group', 0 ); } else { // Move the @wordpress/interactivity package to the footer. wp_script_add_data( 'wp-interactivity', 'group', 1 ); } // Move all the view scripts of the interactive blocks to the footer. $registered_blocks = \WP_Block_Type_Registry::get_instance()->get_all_registered(); foreach ( array_values( $registered_blocks ) as $block ) { if ( isset( $block->supports['interactivity'] ) && $block->supports['interactivity'] ) { foreach ( $block->view_script_handles as $handle ) { // Note that all block view scripts are already made defer by default. wp_script_add_data( $handle, 'group', $supports_defer ? 0 : 1 ); } } } } add_action( 'wp_enqueue_scripts', 'gutenberg_interactivity_move_interactive_scripts_to_the_footer', 11 );