Prints the enqueued script module using script tags with type=”module” attributes.
Parameters
$idstringrequired- The script module identifier.
Source
private function print_script_module( string $id ) {
if ( in_array( $id, $this->done, true ) || ! in_array( $id, $this->queue, true ) ) {
return;
}
$this->done[] = $id;
$src = $this->get_src( $id );
if ( '' === $src ) {
return;
}
$attributes = array(
'type' => 'module',
'src' => $src,
'id' => $id . '-js-module',
);
$script_module = $this->registered[ $id ];
$queued_dependents = array_intersect( $this->queue, $this->get_recursive_dependents( $id ) );
$fetchpriority = $this->get_highest_fetchpriority( array_merge( array( $id ), $queued_dependents ) );
if ( 'auto' !== $fetchpriority ) {
$attributes['fetchpriority'] = $fetchpriority;
}
if ( $fetchpriority !== $script_module['fetchpriority'] ) {
$attributes['data-wp-fetchpriority'] = $script_module['fetchpriority'];
}
wp_print_script_tag( $attributes );
}
Changelog
| Version | Description |
|---|---|
| 6.9.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.