0

I am having an issue in a theme that I am working on and I don't see how to fix it. The theme has a few jquery scripts that it needs loaded into the head in order to work. Without all of them, the theme fails. Here are the ones I am calling

jquery-1.8.2.min.js jquery-1.6.1.min.js jquery.easing.1.3.js jquery-ui-1.8.11.custom.min.js jquery-ui-1.8.21.custom.min.js

now with WordPress, I thought that you could just enqueue jquery and all the versions would be loaded. My problem is that when I try that and remove those scripts above, it all fails. I am enqueueing all the scripts in the functions.php file. I have noticed that when I load some plugins, it also breaks the theme so I am trying to figure out how to get it working so that plugins won't make it crash.

all of my scripts are called like so

 $(function($){
    $(document).ready(function() {
 });
 });

am I missing something?

4
  • 1
    if you are trying to enqueue jQuery from WordPress then i think your theme's other scripts or not compatible with latest version of jQuery, what errors are you getting in firebug, and also correct your noconflict wrapper jQuery(function($) { $(document).ready(function() { ......}); }); – Anjum Sep 8 '13 at 5:30
  • 1
    you're loading two different versions of jquery and two different versions of jquery ui? – Milo Sep 8 '13 at 14:29
  • The theme I am working on has a high number of animation. There are many different scripts that run the site. Right now, it works perfectly. I installed contact form 7 and the site crashed. I just wanted to make sure the site was loading jquery properly. Right now there are many scripts. If I pull one out, the site stops working so they all must be needed. I will try to take out the two different versions Milo and see what happens. I will also try your suggestion Anjum – Jamie Sep 8 '13 at 17:04
  • Milo. I removed the duplicate versions and now contact form 7 does work and the site has not crashed. If you want to add your comment as an answer, I will accept it. – Jamie Sep 8 '13 at 17:17
0

I thought that you could just enqueue jquery and all the versions would be loaded

All version of jQuery? No. That would be foolish. You'd load a tremendous number of resources and have a high probability of conflicts.

If you are referring to the built in dependency handling, then you can enqueue only the dependent script and have the other dependencies load automatically, assuming the scripts are all registered correctly.

I am trying to figure out how to get it working so that plugins won't make it crash.

Some plugins will make the site crash (or break if not actually crash) no matter what you do. Some plugins (many) are poorly written and many have not been updated in a long time. You can't fix those problems by hacking your theme. You can't compensate for the infinite combinations of bad code, old, code and weird code. Write your theme properly and hope for the best. At least you have the moral high ground someone complains.

If you must use an old, bad, weird plugin you will have to hack it into compliance, or write your own to do the same thing, which I'd recommend over reverse engineering and remodeling someone else's strange idea of good code. If it were a decent, up-to-date plugin you wouldn't be asking what is wrong with it or you'd be asking about some obscure edge case.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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