Measure time eval of register_block_type_assets

This commit is contained in:
“Joshua 2024-09-18 15:39:07 -04:00
parent b368bba72e
commit 8ea33e2e0c
1 changed files with 6 additions and 0 deletions

View File

@ -8,6 +8,8 @@ use Automattic\WooCommerce\Blocks\Assets\Api as AssetApi;
use Automattic\WooCommerce\Blocks\Integrations\IntegrationRegistry;
use Automattic\WooCommerce\Admin\Features\Features;
$t = 0;
/**
* AbstractBlock class.
*/
@ -92,7 +94,11 @@ abstract class AbstractBlock {
public function render_callback( $attributes = [], $content = '', $block = null ) {
$render_callback_attributes = $this->parse_render_callback_attributes( $attributes );
if ( ! is_admin() && ! WC()->is_rest_api_request() ) {
global $t;
$s = microtime(true);
$this->register_block_type_assets();
$t += microtime(true) - $s;
error_log('register_block_type_assets ms: ' . $t);
$this->enqueue_assets( $render_callback_attributes, $content, $block );
}
return $this->render( $render_callback_attributes, $content, $block );