On my small site, I load jQuery UI script while using following code:
During my wordpress plugin I personally use the next code:
As a result these two line is put into my header - and loading a script two times is not so good.
Yes, I understand I'm able to take it out of either my wordpress plugin or my website. But the thing is that anybody can download my wordpress plugin, plus they might be loading the jQuery UI script.
How do i avoid getting a script being added two times?
The WP API states the very first param is really a handler. That certain is most likely used so a script is just placed once (although I am unable to say without a doubt).
Additionally, it defines handlers for jQuery and jQuery UI that you simply should most likely use. Individuals handlers are for incorporated scripts and jQuery in addition to jQuery-ui shows up there. If you wish to update consider passing the version towards the wordpress_-function or simply changing the jQuery script file that’s already being used / packed with wordpress.
You can deregister the very first script by putting this line inside your wordpress plugin...
before you decide to call your enqueue_script...
This will take away the first jQuery ask all pages which use your wordpress plugin.
This post on Stack Overflow might be useful regarding how to test if jQuery UI continues to be loaded -