Editor: Avoid Deferring Loading for Empty Block Script URI
In the context of register_block_script_handle, the get_block_asset_url function may return false when an empty string is provided as the input. This behavior is intended to prevent the generation of invalid URLs. However, when the script loading strategy is set to "defer" while passing false, it triggers a "doing it wrong" message. This situation becomes problematic, especially for scenarios where the scripts haven't been built yet. In such cases, the realpath call returns an empty string because the file doesn't exist. To address this issue, we now perform a simple check to ensure that the script URI is not empty before applying the "defer" loading strategy. This adjustment prevents unnecessary deferral of loading for scripts with empty URIs. Follow on from [56683] and [56033]. Props kebbet, mukesh27, swissspidy, westonruter, spacedmonkey. Fixes #59475 Built from https://develop.svn.wordpress.org/trunk@56744 git-svn-id: http://core.svn.wordpress.org/trunk@56256 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
440b8c2aba
commit
d922a9e96a
|
@ -181,7 +181,7 @@ function register_block_script_handle( $metadata, $field_name, $index = 0 ) {
|
|||
$script_uri = get_block_asset_url( $script_path_norm );
|
||||
|
||||
$script_args = array();
|
||||
if ( 'viewScript' === $field_name ) {
|
||||
if ( 'viewScript' === $field_name && $script_uri ) {
|
||||
$script_args['strategy'] = 'defer';
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '6.4-beta1-56743';
|
||||
$wp_version = '6.4-beta1-56744';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue