2

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?

1 Answer 1

4

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. :(

1
  • 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, 2011 at 9:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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