I’m currently authoring the development of a plugin for wordpress, and I’m having trouble figuring out which would be the best way to add scripts to the plugin. I’m in the process of adding more scripts, and I already have JQuery (through WordPress), JQuery UI (through googleapis). Eventually I’ll be adding SWFUpload, but before I continue, I wanted to understand what would be the appropriate approach to my situation.
From what I’ve gathered, and I’m not totally sure if I’m correct on it. There’s 3 different ways to add/enqueue scripts.
- Use the script already built inside WordPress – which I’m wondering could cause some issues with some webmasters using older versions of wordpress.
- Download a stable version and add it to my plugin directory – which basically guarantees that the plugin will use the same version and will always be available.
- Use the ajax.googleapis.com URL linking the script to enqueue – no changes to the version, but can connectivity with the webmaster’s server or the googleapi server be an issue?
The things I’m wondering about, is reliability, speed, and any standards to it, if any.
Always use the built-in versions. Donât waste time with old WordPress installations â other plugins will break there too.
See
wp-includes/script-loader.php
for the list of available files. Quite a lot. 🙂And avoid remote resources. Some (Google) fail to send the scripts gzip compressed to all supporting browsers, others may not be reliable enough. There is also a privacy issue. Not everyone is happy with a log entry on other sites servers each time a user visits
wp-admin
â¦And if another plugin does the right thing and loads the WordPress script parallel to your remote resource you end up with a useless request and possible script conflicts.