[wp-trac] [WordPress Trac] #51709: Feature request / Enhancement: Script version dependencies

WordPress Trac noreply at wordpress.org
Thu Nov 5 10:29:28 UTC 2020


#51709: Feature request / Enhancement: Script version dependencies
-----------------------------+---------------------------------------
 Reporter:  keraweb          |      Owner:  (none)
     Type:  feature request  |     Status:  new
 Priority:  normal           |  Milestone:  Awaiting Review
Component:  Script Loader    |    Version:
 Severity:  normal           |   Keywords:  dev-feedback needs-design
  Focuses:                   |
-----------------------------+---------------------------------------
 I couldn't find a similar ticket though I can hardly imagine no-one has
 asked this before.
 Anyhow, sorry if this is duplicate!

 Currently you can add script dependencies, which is already working very
 neat.
 However, I think enhancing this feature with version dependencies would
 greatly enhance this part and allow plugins to re-use existing scripts if
 the version params support them.
 This could also prevent some plugins from adding duplicate scripts.

 Examples,

 Register/Enqueue:

 {{{
 wp_register_script(
     'myscript',
     $url,
     array (
         'jquery' => '^1.12', // Any 1.x version higher than 1.12.
         'bootstrap' => '4.*', // Any 4.x version
     ),
     3.6
 );
 }}}

 Checking if version exists:

 {{{
 wp_script_is( 'myscript', 'registered', '>3' );
 }}}

 This would also allow registering multiple scripts under the same handle
 but on a different version.

 I can imagine a next step would be a script/asset manager through the UI
 where you could optionally dequeue some redundant scripts. For example,
 different versions of Bootstrap.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/51709>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list