Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement load handlers #50

Merged
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
04aabf5
numbered attributes
kt-12 Mar 10, 2023
e366d5d
onload script
kt-12 Mar 10, 2023
0fafd88
fix bug
kt-12 Mar 10, 2023
386022e
sprintf issue with \n
kt-12 Mar 11, 2023
fe7acc0
phpcs fixes
kt-12 Mar 11, 2023
394405f
print template loader script
kt-12 Mar 11, 2023
cc5dace
\n to EOL
kt-12 Mar 11, 2023
b558f34
Loading the script before other script
kt-12 Mar 13, 2023
f04a246
temp commit
kt-12 Mar 14, 2023
b5f4df4
check if any delayed inline scripts
kt-12 Mar 15, 2023
d9a0f39
Merge add_text_template to implement_load_handlers
kt-12 Mar 15, 2023
d110556
add new line
kt-12 Mar 16, 2023
b6b7022
backward compatibility
kt-12 Mar 16, 2023
9e8c378
update test utility and scripts.
kt-12 Mar 16, 2023
ffc40c1
php cs fixes
kt-12 Mar 16, 2023
8af918c
fix csfix issue
kt-12 Mar 16, 2023
d952da5
Update test message.
kt-12 Mar 21, 2023
b71b557
Update test comment
kt-12 Mar 21, 2023
479d656
Update test error message
kt-12 Mar 21, 2023
968d5b7
change function names
kt-12 Mar 21, 2023
ad9d9c3
Merge branch 'enhancement/implement_load_handlers' of https://github.…
kt-12 Mar 21, 2023
326555d
use unregister column
kt-12 Mar 22, 2023
6187dd1
Merge branch 'enhancement/add_text_template' into enhancement/impleme…
kt-12 Mar 22, 2023
1321d6f
avoid removal of jquery libraries
kt-12 Mar 23, 2023
66ab60c
Dataprovider doc block.
kt-12 Mar 23, 2023
bbdad37
doc block change
kt-12 Mar 23, 2023
966be0c
Update src/wp-includes/class-wp-scripts.php
kt-12 Mar 28, 2023
dcbf0af
Update doc text
kt-12 Mar 31, 2023
8e08454
Merge branch 'enhancement/add_text_template' into enhancement/impleme…
kt-12 Mar 31, 2023
b3f7225
fix type_attr no there issue
kt-12 Mar 31, 2023
4df5288
adding description
kt-12 Mar 31, 2023
264853c
broke standalone script test to multiple function
kt-12 Mar 31, 2023
556ae91
non-standalone after script test broken
kt-12 Mar 31, 2023
d4be88d
before standalone test broken
kt-12 Mar 31, 2023
180a6ae
non standalone with before and defer
kt-12 Mar 31, 2023
4d0140d
used function instead of arrow function.
kt-12 Mar 31, 2023
a5b83a4
single condition
kt-12 Mar 31, 2023
0269128
put back handle
kt-12 Mar 31, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 36 additions & 2 deletions src/wp-includes/class-wp-scripts.php
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,14 @@ public function do_item( $handle, $group = false ) {
$after_non_standalone_handle = $this->print_inline_script( $handle, 'after-non-standalone', false );

if ( $after_non_standalone_handle ) {
$after_handle .= sprintf( "<script%s id='%s-js-after' type='text/template'>\n%s\n</script>\n", $this->type_attr, esc_attr( $handle ), $after_non_standalone_handle );
$after_handle .= sprintf(
'<script%1$s id=\'%2$s-js-after\' type=\'text/template\' data-wp-executes-after=\'%2$s\'>%4$s%3$s%4$s</script>%4$s',
$this->type_attr,
esc_attr( $handle ),
$after_non_standalone_handle,
PHP_EOL

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
'<script%1$s id=\'%2$s-js-after\' type=\'text/template\' data-wp-executes-after=\'%2$s\'>%4$s%3$s%4$s</script>%4$s',
$this->type_attr,
esc_attr( $handle ),
$after_non_standalone_handle,
PHP_EOL
'<script%s id=\'%2$s-js-after\' type=\'text/template\' data-wp-executes-after=\'%s\'>\n%s\n</script>\n',
$this->type_attr,
esc_attr( $handle ),
$after_non_standalone_handle,

Similar to other scripts, use \n instead of PHP_EOL and use %s as it is sufficient for these changes as we don't need to add translators or change the order of the arguments.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mukeshpanchal27 I was trying the same initially but \n don't work when the parent string is in single quotes. It is instead printed as string \n. Numbered placeholder was added as there are multiple places i wanted the handle string and for numbered placeholder I need the enclosing string to be in single quotes.

);
$this->has_load_later_inline = true;
}
}

Expand Down Expand Up @@ -410,6 +417,9 @@ public function do_item( $handle, $group = false ) {

if ( '' !== $strategy ) {
$strategy = ' ' . $strategy;
if ( ! empty( $after_non_standalone_handle ) ) {
$strategy .= sprintf( " onload='wpLoadAfterScripts(\"%s\")'", esc_attr( $handle ) );
}
}
$tag = $translations . $cond_before . $before_handle;
$tag .= sprintf(
Expand Down Expand Up @@ -499,7 +509,14 @@ public function print_inline_script( $handle, $position = 'after', $display = tr

if ( $display ) {
if ( 'after-non-standalone' === $position ) {
printf( "<script%s id='%s-js-after' type='text/template'>\n%s\n</script>\n", $this->type_attr, esc_attr( $handle ), esc_attr( $position ), $output );
printf(
'<script%1$s id=\'%2$s-js-after\' type=\'text/template\' data-wp-executes-after=\'%2$s\'>%5$s%4$s%5$s</script>%5$s',
$this->type_attr,
esc_attr( $handle ),
esc_attr( $position ),
$output,
PHP_EOL
);
} else {
printf( "<script%s id='%s-js-%s'>\n%s\n</script>\n", $this->type_attr, esc_attr( $handle ), esc_attr( $position ), $output );
}
Expand Down Expand Up @@ -771,6 +788,23 @@ public function add_data( $handle, $key, $value ) {
return parent::add_data( $handle, $key, $value );
}

/**
* Check all handles for any delayed inline scripts.
kt-12 marked this conversation as resolved.
Show resolved Hide resolved
*

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Since annotation is missing.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mukeshpanchal27 We haven't fixed on the final @since yet. We have a separate task for this.

* @return bool True if script present. False if empty.
kt-12 marked this conversation as resolved.
Show resolved Hide resolved
*/
public function maybe_has_delayed_inline_script() {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kt-12 this is a nitpick comment I guess, but I am wondering if maybe is the correct wording here, as it seems to be like you are indefinitely checking of a deferred or async script has inline scripts? This is not a case of maybe and seems like it's more a definite outcome?

If you agree, let's rename this to has_delayed_inline_script() as that is more true to the logic here.

If I've misunderstood, please comment as such thank you :)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are correct. I used maybe as there are certain cases where the final strategy of a script might change before we print them effecting it's inline scripts decision. For example a defer may change to blocking, but we never know it in print_scripts action.

But i do agree maybe is not needed here, i'll remove that.

foreach ( $this->registered as $handle => $script ) {
if ( in_array( $this->get_intended_strategy( $handle ), array( 'defer', 'async' ), true ) ) {
// non standalone after scripts of async or defer are usually delayed.
if ( $this->has_non_standalone_inline_script( $handle, 'after' ) ) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These could be combined into a single if statement with &&

return true;
}
}
}
return false;
}

/**
* Normalize the data inside the $args parameter and support backward compatibility.
*
Expand Down
1 change: 1 addition & 0 deletions src/wp-includes/default-filters.php
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,7 @@
add_action( 'enqueue_block_editor_assets', 'wp_enqueue_editor_format_library_assets' );
add_action( 'enqueue_block_editor_assets', 'wp_enqueue_global_styles_css_custom_properties' );
add_filter( 'wp_print_scripts', 'wp_just_in_time_script_localization' );
add_action( 'wp_print_scripts', 'wp_print_template_loader_script' );
add_filter( 'print_scripts_array', 'wp_prototype_before_jquery' );
add_filter( 'customize_controls_print_styles', 'wp_resource_hints', 1 );
add_action( 'admin_head', 'wp_check_widget_editor_deps' );
Expand Down
20 changes: 20 additions & 0 deletions src/wp-includes/script-loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -1843,6 +1843,26 @@ function wp_just_in_time_script_localization() {
);
}


/**
* Prints a loader script if there is text/template registered script.
*/

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per PHP Documentation Standards, Use proper format for function

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated. Usage of since is still missing as this will be handled together for the entire functionality in a separate task. Thanks @mukeshpanchal27.

function wp_print_template_loader_script() {
$wp_scripts = wp_scripts();
if ( $wp_scripts->maybe_has_delayed_inline_script() ) {
$output = <<<JS
let wpLoadAfterScripts = ( handle ) => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could probably be a regular function rather than an arrow function.

function wpLoadAfterScripts( handle ) {
  // functionality
}

let scripts = document.querySelectorAll(`[type="text/template"][data-wp-executes-after="\${handle}"]`);
scripts.forEach( (script) => {
script.setAttribute("type","text/javascript");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
script.setAttribute("type","text/javascript");

WP use $this->type_attr for script type. Please correct me if i miss anything.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mukeshpanchal27 this is the JS code for modifying type after a script is loaded on the DOM. So we can't use $this->type_attr

eval(script.innerHTML);
})
}
JS;
printf( "<script id='wp-executes-after-js'>\n%s\n</script>\n", $output );

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$this->type_attr is missing in script.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed, but $this->type_attr is not available here so replicate the way function _print_scripts() was handling the same scenario.

}
}

/**
* Localizes the jQuery UI datepicker.
*
Expand Down
8 changes: 8 additions & 0 deletions tests/phpunit/includes/utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -645,3 +645,11 @@ function test_rest_expand_compact_links( $links ) {
}
return $links;
}

/**
* Removes all handles from $wp_script.
*/
function unregister_all_script_handles() {
global $wp_scripts;
$wp_scripts->registered = array();
}
101 changes: 75 additions & 26 deletions tests/phpunit/tests/dependencies/scripts.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,17 +71,30 @@ public function test_wp_enqueue_script() {
*/
public function test_non_standalone_and_standalone_after_script_combined() {
// If the main script with defer strategy has a `after` inline script; expected one with type='javascript' and other with type='module'.
kt-12 marked this conversation as resolved.
Show resolved Hide resolved
unregister_all_script_handles();
wp_enqueue_script( 'ms-isinsa-1', 'http://example.org/ms-isinsa-1.js', array(), null, array( 'strategy' => 'defer' ) );
wp_add_inline_script( 'ms-isinsa-1', 'console.log("after one");', 'after', true );
wp_add_inline_script( 'ms-isinsa-1', 'console.log("after two");', 'after' );
$output = get_echo( 'wp_print_scripts' );
$expected = "<script type='text/javascript' src='http://example.org/ms-isinsa-1.js' id='ms-isinsa-1-js' defer></script>\n";
$expected .= "<script type='text/javascript' id='ms-isinsa-1-js-after'>\n";
$expected .= "console.log(\"after one\");\n";
$expected .= "</script>\n";
$expected .= "<script type='text/javascript' id='ms-isinsa-1-js-after' type='text/template'>\n";
$expected .= "console.log(\"after two\");\n";
$expected .= "</script>\n";
$output = get_echo( 'wp_print_scripts' );
$expected = <<<EXP
<script id='wp-executes-after-js'>
let wpLoadAfterScripts = ( handle ) => {
let scripts = document.querySelectorAll(`[type="text/template"][data-wp-executes-after="\${handle}"]`);
scripts.forEach( (script) => {
script.setAttribute("type","text/javascript");
eval(script.innerHTML);
})
}
</script>
<script type='text/javascript' src='http://example.org/ms-isinsa-1.js' id='ms-isinsa-1-js' defer onload='wpLoadAfterScripts("ms-isinsa-1")'></script>
<script type='text/javascript' id='ms-isinsa-1-js-after'>
console.log("after one");
</script>
<script type='text/javascript' id='ms-isinsa-1-js-after' type='text/template' data-wp-executes-after='ms-isinsa-1'>
console.log("after two");
</script>

EXP;
$this->assertSame( $expected, $output );
}

Expand All @@ -99,6 +112,7 @@ public function data_standalone_after_inline_script() {
$data = array();

// If the main script with defer strategy has a `after` inline script; the inline script is not affected.
unregister_all_script_handles();
wp_enqueue_script( 'ms-isa-1', 'http://example.org/ms-isa-1.js', array(), null, array( 'strategy' => 'defer' ) );
wp_add_inline_script( 'ms-isa-1', 'console.log("after one");', 'after', true );
$output = get_echo( 'wp_print_scripts' );
Expand All @@ -109,6 +123,7 @@ public function data_standalone_after_inline_script() {
array_push( $data, array( $expected, $output, 'Expected no type attribute for inline script.' ) );

// If the main script with async strategy has a `after` inline script; the inline script is not affected.
unregister_all_script_handles();
wp_enqueue_script( 'ms-isa-2', 'http://example.org/ms-isa-2.js', array(), null, array( 'strategy' => 'defer' ) );
wp_add_inline_script( 'ms-isa-2', 'console.log("after one");', 'after', true );
$output = get_echo( 'wp_print_scripts' );
Expand All @@ -135,44 +150,72 @@ public function data_non_standalone_after_inline_script() {
$data = array();

// If the main script with defer strategy has a `after` inline script; the inline script is inserted as type='module'.
unregister_all_script_handles();
wp_enqueue_script( 'ms-insa-1', 'http://example.org/ms-insa-1.js', array(), null, array( 'strategy' => 'defer' ) );
wp_add_inline_script( 'ms-insa-1', 'console.log("after one");', 'after' );
$output = get_echo( 'wp_print_scripts' );
$expected = "<script type='text/javascript' src='http://example.org/ms-insa-1.js' id='ms-insa-1-js' defer></script>\n";
$expected .= "<script type='text/javascript' id='ms-insa-1-js-after' type='text/template'>\n";
$expected .= "console.log(\"after one\");\n";
$expected .= "</script>\n";
array_push( $data, array( $expected, $output, 'Expected type="text/template" for inline script.' ) );
$output = get_echo( 'wp_print_scripts' );
$expected = <<<EXP
<script id='wp-executes-after-js'>
let wpLoadAfterScripts = ( handle ) => {
let scripts = document.querySelectorAll(`[type="text/template"][data-wp-executes-after="\${handle}"]`);
scripts.forEach( (script) => {
script.setAttribute("type","text/javascript");
eval(script.innerHTML);
})
}
</script>
<script type='text/javascript' src='http://example.org/ms-insa-1.js' id='ms-insa-1-js' defer onload='wpLoadAfterScripts("ms-insa-1")'></script>
<script type='text/javascript' id='ms-insa-1-js-after' type='text/template' data-wp-executes-after='ms-insa-1'>
console.log("after one");
</script>

EXP;
array_push( $data, array( $expected, $output, 'Main Deferred; expected type="text/template" for inline script.' ) );

// If the main script with async strategy has a `after` inline script; the inline script is inserted as type='module'.
wp_enqueue_script( 'ms-insa-2', 'http://example.org/ms-insa-2.js', array(), null, array( 'strategy' => 'defer' ) );
unregister_all_script_handles();
wp_enqueue_script( 'ms-insa-2', 'http://example.org/ms-insa-2.js', array(), null, array( 'strategy' => 'async' ) );
wp_add_inline_script( 'ms-insa-2', 'console.log("after one");', 'after' );
$output = get_echo( 'wp_print_scripts' );
$expected = "<script type='text/javascript' src='http://example.org/ms-insa-2.js' id='ms-insa-2-js' defer></script>\n";
$expected .= "<script type='text/javascript' id='ms-insa-2-js-after' type='text/template'>\n";
$expected .= "console.log(\"after one\");\n";
$expected .= "</script>\n";
array_push( $data, array( $expected, $output, 'Expected type="text/template" for inline script.' ) );
$output = get_echo( 'wp_print_scripts' );
$expected = <<<EXP
<script id='wp-executes-after-js'>
let wpLoadAfterScripts = ( handle ) => {
let scripts = document.querySelectorAll(`[type="text/template"][data-wp-executes-after="\${handle}"]`);
scripts.forEach( (script) => {
script.setAttribute("type","text/javascript");
eval(script.innerHTML);
})
}
</script>
<script type='text/javascript' src='http://example.org/ms-insa-2.js' id='ms-insa-2-js' async onload='wpLoadAfterScripts("ms-insa-2")'></script>
<script type='text/javascript' id='ms-insa-2-js-after' type='text/template' data-wp-executes-after='ms-insa-2'>
console.log("after one");
</script>

EXP;
array_push( $data, array( $expected, $output, 'Main Async; expected type="text/template" for inline script.' ) );

// If the main script with blocking strategy has a `after` inline script; the inline script is inserted as type='javascript'.
unregister_all_script_handles();
wp_enqueue_script( 'ms-insa-3', 'http://example.org/ms-insa-3.js', array(), null, array( 'strategy' => 'blocking' ) );
wp_add_inline_script( 'ms-insa-3', 'console.log("after one");', 'after' );
$output = get_echo( 'wp_print_scripts' );
$expected = "<script type='text/javascript' src='http://example.org/ms-insa-3.js' id='ms-insa-3-js'></script>\n";
$expected .= "<script type='text/javascript' id='ms-insa-3-js-after'>\n";
$expected .= "console.log(\"after one\");\n";
$expected .= "</script>\n";
array_push( $data, array( $expected, $output, 'Expected no type attribute for inline script.' ) );
array_push( $data, array( $expected, $output, 'Main blocking; expected no type attribute for inline script.' ) );
kt-12 marked this conversation as resolved.
Show resolved Hide resolved

// If the main script with no strategy has a `after` inline script; the inline script is inserted as type='javascript'.
unregister_all_script_handles();
wp_enqueue_script( 'ms-insa-4', 'http://example.org/ms-insa-4.js', array(), null );
wp_add_inline_script( 'ms-insa-4', 'console.log("after one");', 'after' );
$output = get_echo( 'wp_print_scripts' );
$expected = "<script type='text/javascript' src='http://example.org/ms-insa-4.js' id='ms-insa-4-js'></script>\n";
$expected .= "<script type='text/javascript' id='ms-insa-4-js-after'>\n";
$expected .= "console.log(\"after one\");\n";
$expected .= "</script>\n";
array_push( $data, array( $expected, $output, 'Expected no type attribute for inline script.' ) );
array_push( $data, array( $expected, $output, 'No strategy; expected no type attribute for inline script.' ) );
kt-12 marked this conversation as resolved.
Show resolved Hide resolved

return $data;
}
Expand All @@ -191,6 +234,7 @@ public function data_non_standalone_before_inline_script_with_defer() {
$data = array();

// If the main script has a `before` inline script; all dependencies will be blocking.
unregister_all_script_handles();
wp_enqueue_script( 'ds-i1-1', 'http://example.org/ds-i1-1.js', array(), null, array( 'strategy' => 'defer' ) );
wp_enqueue_script( 'ds-i1-2', 'http://example.org/ds-i1-2.js', array(), null, array( 'strategy' => 'defer' ) );
wp_enqueue_script( 'ds-i1-3', 'http://example.org/ds-i1-3.js', array(), null, array( 'strategy' => 'defer' ) );
Expand All @@ -207,6 +251,7 @@ public function data_non_standalone_before_inline_script_with_defer() {
array_push( $data, array( $expected, $output, 'All dependency in the chain should be blocking' ) );

// One of the dependency in the chain has a `before` inline script; all script above it will be blocking.
unregister_all_script_handles();
wp_enqueue_script( 'ds-i2-1', 'http://example.org/ds-i2-1.js', array(), null, array( 'strategy' => 'defer' ) );
wp_enqueue_script( 'ds-i2-2', 'http://example.org/ds-i2-2.js', array( 'ds-i2-1' ), null, array( 'strategy' => 'defer' ) );
wp_enqueue_script( 'ds-i2-3', 'http://example.org/ds-i2-3.js', array( 'ds-i2-2' ), null, array( 'strategy' => 'defer' ) );
Expand All @@ -223,6 +268,7 @@ public function data_non_standalone_before_inline_script_with_defer() {
array_push( $data, array( $expected, $output, 'Scripts in the chain before the script having before must be blocking.' ) );

// Top most dependency in the chain has a `before` inline script; none of the script bellow it will be blocking.
unregister_all_script_handles();
wp_enqueue_script( 'ds-i3-1', 'http://example.org/ds-i3-1.js', array(), null, array( 'strategy' => 'defer' ) );
wp_enqueue_script( 'ds-i3-2', 'http://example.org/ds-i3-2.js', array( 'ds-i3-1' ), null, array( 'strategy' => 'defer' ) );
wp_enqueue_script( 'ms-i3-1', 'http://example.org/ms-i3-1.js', array( 'ds-i3-2' ), null, array( 'strategy' => 'defer' ) );
Expand All @@ -237,6 +283,7 @@ public function data_non_standalone_before_inline_script_with_defer() {
array_push( $data, array( $expected, $output, 'Top most has before inline script. All the script in the chain defer.' ) );

// If there are two dependencies chain; rules are applied to the scripts in the chain having a `before` inline script.
unregister_all_script_handles();
wp_enqueue_script( 'ch1-ds-i4-1', 'http://example.org/ch1-ds-i4-1.js', array(), null, array( 'strategy' => 'defer' ) );
wp_enqueue_script( 'ch1-ds-i4-2', 'http://example.org/ch1-ds-i4-2.js', array( 'ch1-ds-i4-1' ), null, array( 'strategy' => 'defer' ) );
wp_enqueue_script( 'ch2-ds-i4-1', 'http://example.org/ch2-ds-i4-1.js', array(), null, array( 'strategy' => 'defer' ) );
Expand All @@ -261,16 +308,17 @@ public function data_non_standalone_before_inline_script_with_defer() {
* Test standalone tests.
*
* @ticket 12009
* @dataProvider data_standalone_inline_script
* @dataProvider data_standalone_before_inline_script
*/
public function test_standalone_inline_script( $expected, $output, $message ) {
public function test_standalone_before_inline_script( $expected, $output, $message ) {
$this->assertSame( $expected, $output, $message );
}

public function data_standalone_inline_script() {
public function data_standalone_before_inline_script() {
$data = array();

// If the main script has a `before` inline script; standalone doesn't effect any script.
unregister_all_script_handles();
wp_enqueue_script( 'ds-is1-1', 'http://example.org/ds-is1-1.js', array(), null, array( 'strategy' => 'defer' ) );
wp_enqueue_script( 'ds-is1-2', 'http://example.org/ds-is1-2.js', array(), null, array( 'strategy' => 'defer' ) );
wp_enqueue_script( 'ds-is1-3', 'http://example.org/ds-is1-3.js', array(), null, array( 'strategy' => 'defer' ) );
Expand All @@ -287,6 +335,7 @@ public function data_standalone_inline_script() {
array_push( $data, array( $expected, $output, 'All dependency in the chain should be blocking' ) );

// One of the dependency in the chain has a `before` inline script; standalone doesn't effect any script.
unregister_all_script_handles();
wp_enqueue_script( 'ds-is2-1', 'http://example.org/ds-is2-1.js', array(), null, array( 'strategy' => 'defer' ) );
wp_enqueue_script( 'ds-is2-2', 'http://example.org/ds-is2-2.js', array( 'ds-is2-1' ), null, array( 'strategy' => 'defer' ) );
wp_enqueue_script( 'ds-is2-3', 'http://example.org/ds-is2-3.js', array( 'ds-is2-2' ), null, array( 'strategy' => 'defer' ) );
Expand Down