[wp-trac] [WordPress Trac] #61500: Script Modules: Allow scripts to depend on modules

WordPress Trac noreply at wordpress.org
Wed Oct 1 11:22:02 UTC 2025


#61500: Script Modules: Allow scripts to depend on modules
-------------------------------------+-------------------------------------
 Reporter:  jonsurrell               |       Owner:  (none)
     Type:  enhancement              |      Status:  new
 Priority:  normal                   |   Milestone:  Awaiting Review
Component:  Script Loader            |     Version:  6.5
 Severity:  normal                   |  Resolution:
 Keywords:  has-patch has-unit-      |     Focuses:  javascript,
  tests                              |  performance
-------------------------------------+-------------------------------------
Description changed by jonsurrell:

Old description:

> WordPress supports JavaScript modules via the Script Modules API.
>
> Classic Scripts would benefit from the use of Script Modules to take
> advantage of some benefits like conditional and deferred loading, but
> classic Scripts have no way of declaring a dependency on Script Modules.
>
> Classic scripts can use the "dynamic" `import( 'module-id' )` to import
> JavaScript modules, but there's currently no way to declare the
> dependency so that dependent modules are included in the import map,
> making this usage problematic in WordPress.
>
> Ideally, Scripts should be able declare Script Module dependencies so
> that scripts can safely use modules.
>
> This complements https://core.trac.wordpress.org/ticket/60647 which seeks
> to add more functionality to Script Modules.

New description:

 WordPress supports JavaScript modules via the Script Modules API.

 Classic Scripts would benefit from the use of Script Modules to take
 advantage of some benefits like conditional and deferred loading, but
 classic Scripts have no way of declaring a dependency on Script Modules.

 Classic scripts can use the "dynamic" `import( 'module-id' )` to import
 JavaScript modules, but there's currently no way to declare the dependency
 so that dependent modules are included in the import map, making this
 usage problematic in WordPress.

 Ideally, Scripts should be able declare Script Module dependencies so that
 scripts can safely use modules.

 This complements #60647 which seeks to add more functionality to Script
 Modules.

--

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/61500#comment:9>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list