Assets::register_block_script()public staticWC 2.3.0

Deprecated from version 4.5.0 Block types register the scripts themselves.. It is no longer supported and can be removed in future releases. It is recommended to replace this function with the same one.

Queues a block script in the frontend.

Method of the class: Assets{}

No Hooks.


null. Nothing.


$result = Assets::register_block_script( $script_name, $handle, $dependencies );
$script_name(string) (required)
Name of the script used to identify the file inside build folder.
Provided if the handle should be different than the script name. wc- prefix automatically added.
Default: ''
An array of registered script handles this script depends on.
Default: empty array


Since 2.3.0 Introduced.
Since 2.6.0 Changed $name to $script_name and added $handle argument.
Since 2.9.0 Made it so scripts are not loaded in admin pages.
Deprecated since 4.5.0 Block types register the scripts themselves.

Assets::register_block_script() code WC 7.7.0

public static function register_block_script( $script_name, $handle = '', $dependencies = [] ) {
	_deprecated_function( 'register_block_script', '4.5.0' );
	$asset_api = Package::container()->get( AssetApi::class );
	$asset_api->register_block_script( $script_name, $handle, $dependencies );