When I searched the web for how I should include third party librarys I only found many results that described this way. But that won’t help me.
Right now I have this problem with a plugin, but it would be nice to have a solution which also works if I have this problem with a theme.
You need to use wp_script_is in order to check if the library you are willing to use has already been included by another plugin. As you can see the handle is important, if you change it to whatEverIWant.js, it will not recognize the library.
There’s no real way that developers would be able to achieve this. This is mostly because:
However, if you are using a well-known and popular library which is included in WordPress too, you can check if it is loaded already by using the following function:
wp_script_is( $name, $list = 'enqueued' );
This will return
true if the script is already printed/enqueued/registered so you can use it with conjunction of an
if() to decide whether you should print it again or not.
But as i mentioned above, if the names are not the same, this won’t work.