Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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.

  1. Use the script already built inside WordPress - which I'm wondering could cause some issues with some webmasters using older versions of wordpress.
  2. 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.
  3. 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.

share|improve this question

1 Answer 1

up vote 2 down vote accepted

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.

share|improve this answer
    
2&3 - you'll probably break plug-ins that are expecting the built-in version. –  Stephen Harris Jul 19 '12 at 10:26

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.