I’ll answer each of your questions in order:
Do we care which scripts are enqueued?
Not really. WordPress registers each script and maintains it in an array. When you enqueue the script, WordPress will load it and any dependencies it has when it calls wp_print_scripts()
(which is tied to the wp_head
hook).
If you enqueue a script twice, it’s only printed once. So don’t worry about it. Just always enqueue what you need.
What about script versions?
WordPress will only let you register one version of a script. So if an older version is already registered, you can’t register the new one.
Calling wp_enqueue_script()
with the new version won’t actually enqueue it, either. When you try to enqueue a script with the full URI, WordPress will first register the script, then enqueue it … so if an older version is already registered, you’ll end up enqueuing it instead.
If you absolutely need to enqueue a new version (i.e. you want to use the latest version of jQuery rather than the one that ships with WordPress), you need to first unregister the old version, then register/enqueue the new version.
Someone else has already covered how to do this in another question, so I’ll just refer you there …