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.

Many wordpress theme, plugin, and widget developers seem to think that the only way to use jquery on the page is to include their own copy. On some pages of the site I'm developing, there are as many as six different places where I see various different copies of jquery included. This is ridiculous. It increases loading time, and is totally redundant.

Is there any easy way, either through a plugin or a bit of my own coding, to force only one copy of jquery to be included on each page? There's already a jquery.js in the /wp-includes/js/jquery/ directory, which should suffice for any plugin that needs it. How can I automatically remove all of the other references to it on the page?

share|improve this question

1 Answer 1

up vote 4 down vote accepted

There is no blanket solution to this.

  1. If developer has a clue - he will reuse bundled jQuery or re-register it to other copy (commonly done to load jQuery from Google's CDN).

  2. Otherwise there are a lot of [insane] ways to add jQuery and there is no way to handle them all without global output buffering or tweaking hooks/plugins individually.

Overall it is often better plugins from good developers than waste time on tweaking poorly coded plugins. But if you already stuck with bunch of poor plugins - you are in for some manual cleanup. :(

share|improve this answer
4  
And when you clean up the files so that they use wp_enqueue_script, be sure to mail your changes to the original developer of your plugin or theme. If they include it in the next release you will have improved the world for all of us! –  Jan Fabry Feb 8 '11 at 9:09

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.