Severely Over Complicated jQuery Load Process

I have seen a lot of ways to load custom versions of jQuery, but this is probably the most “robust”, though I don’t mean that in a good way.

WordPress makes it really easy to load jQuery by simply doing:

wp_enqueue_script( 'jquery' )

Some developers believe it is better to force WordPress to use other versions of jQuery from google (or elsewhere). This is a practice I strongly disagree with. You can read about why I feel this practice is really irresponsible on Pippin’s Plugins.

Anyhow this particular developer went really far and decided to build an overly complex system for loading a custom version of jQuery, and all for a really simple tabs / accordion plugin. Here it is:

Now, I really do not like talking badly of others, so please note that I am NOT criticizing this developer personally. It is very likely that this was developed due to his or her own experiences and frustrations with the all-to-common jQuery conflict. I’m posting this not as a insult to whoever wrote this, but as an example of why theme and plugin developers should almost never load their own jQuery. The practice of loading jQuery from Google has resulted in developers needing to find elaborate solutions like this, when really it’s way simpler: if everyone did it correctly by just allowing WordPress to handle the version of jQuery loaded, we’d never have these problems.

Submitted by Josh Feck.

Custom jQuery

Loading custom jQuery is the single cause for a huge number of the support tickets I handle. Sometimes developers decide to load jQuery from Google, sometimes they include a version with their plugin files, sometimes they enqueue it semi-properly, and sometimes they don’t even enqueue it. This snippet is an example of all the bad ways to load jQuery in a plugin.
Continue reading