As other have mentioned , there is no great answer to this, ultimately you cannot control how other people write plugins/themes and there are no standards for naming wp_enqueue_script
‘s, though there probably should be.
Also there is no current way to check if jQuery is loaded using wp_enqueue_script
, though this is very easy to do at the template level with something like window.jQuery
.
Some notes, since this gets bit weird:
Scenario 1 – Same name
If you use the name jquery
to enqueue your script, for example:
wp_enqueue_script( 'jquery', '/ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js');
It will not enqueue ^ this link , but instead use the default WordPress bundled jQuery which is:
wp-includes/js/jquery/jquery.js?ver=x.x.x (latest bundled)
The reason is your using the same name, a name registered by WordPress first.
Scenario 2 – Diff name
If you use a different name, for example:
wp_enqueue_script( 'jquery-hi','/ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js');
It will just enqueue jquery-hi
and not the bundled WordPress jQuery.
Scenario 3 –Multiple names
If you have several plugins/themes using different names, such as:
wp_enqueue_script( 'jquery-hi','/ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js');
wp_enqueue_script( 'jquery-pie','/ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js');
It will enqueue both of them.
ps. Don’t load your own jQuery (or other bundled wp script) in the admin, ever.