[wp-trac] [WordPress Trac] #61734: Add the ability to handle "fetchpriority" to ES Modules and Import Maps
WordPress Trac
noreply at wordpress.org
Thu Oct 23 18:42:50 UTC 2025
#61734: Add the ability to handle "fetchpriority" to ES Modules and Import Maps
-------------------------------------+-------------------------------------
Reporter: dennysdionigi | Owner: westonruter
Type: enhancement | Status: closed
Priority: normal | Milestone: 6.9
Component: Script Loader | Version: 6.5
Severity: minor | Resolution: fixed
Keywords: has-patch has-unit- | Focuses: javascript,
tests needs-dev-note | performance
-------------------------------------+-------------------------------------
Comment (by westonruter):
There are [https://github.com/johnbillion/query-
monitor/blob/f7ec89b87d88bd66f68bca52d2e4f2c679b63c04/classes/Collector_Assets.php#L293-L305
four methods] we potentially need to ensure remain compatible:
* `get_marked_for_enqueue()`
* `get_dependencies()`
* `get_src()`
@johnbillion The first one now has a public API in the `get_queue()`
method.
For `get_dependencies()`, it will be simply to restore the previous
interface. I've got this drafted:
{{{#!diff
index 838c0eaf9c..cd9a81b99c 100644
--- a/src/wp-includes/class-wp-script-modules.php
+++ b/src/wp-includes/class-wp-script-modules.php
@@ -398,7 +398,7 @@ class WP_Script_Modules {
! $this->registered[ $id ]['in_footer']
) {
// If any dependency is set to be printed
in footer, skip printing this module in head.
- $dependencies = $this->get_dependencies(
array( $id ) );
+ $dependencies = array_keys(
$this->get_dependencies( array( $id ) ) );
foreach ( $dependencies as $dependency_id
) {
if (
in_array( $dependency_id,
$this->queue, true ) &&
@@ -528,7 +528,7 @@ class WP_Script_Modules {
*/
private function get_import_map(): array {
$imports = array();
- foreach ( $this->get_dependencies( $this->queue ) as $id )
{
+ foreach ( array_keys( $this->get_dependencies(
$this->queue ) ) as $id ) {
$src = $this->get_src( $id );
if ( '' !== $src ) {
$imports[ $id ] = $src;
@@ -566,7 +566,7 @@ class WP_Script_Modules {
* @param string[] $ids The identifiers of the script
modules for which to gather dependencies.
* @param string[] $import_types Optional. Import types of
dependencies to retrieve: 'static', 'dynamic', or both.
* Default is both.
- * @return string[] List of IDs for script module dependencies.
+ * @return array<string, array> Script modules keyed by ID.
*/
private function get_dependencies( array $ids, array $import_types
= array( 'static', 'dynamic' ) ): array {
$all_dependencies = array();
@@ -584,7 +584,7 @@ class WP_Script_Modules {
in_array( $dependency['import'],
$import_types, true ) &&
isset( $this->registered[
$dependency['id'] ] )
) {
- $all_dependencies[
$dependency['id'] ] = true;
+ $all_dependencies[
$dependency['id'] ] = $this->registered[ $dependency['id'] ];
// Add this dependency to the list
to get dependencies for.
$id_queue[] = $dependency['id'];
@@ -592,7 +592,7 @@ class WP_Script_Modules {
}
}
- return array_keys( $all_dependencies );
+ return $all_dependencies;
}
/**
}}}
This seems preferable for you, right?
--
Ticket URL: <https://core.trac.wordpress.org/ticket/61734#comment:55>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list