Opened 3 months ago
Closed 12 hours ago
#51709 closed feature request (duplicate)
Feature request / Enhancement: Script version dependencies
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | |
Component: | Script Loader | Keywords: | dev-feedback needs-design |
Focuses: | Cc: |
Description
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.
Hi there, welcome back to WordPress Trac!
Thanks for the ticket, we're already tracking this feature request in #47285.