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

I'm working on themeing a single site of a multi-site Drupal install. The organization that set up the site has jquery 1.2.6 installed which is fine for most things... but as I'm planning on using a few other javascript libraries and maybe a few $.ajax calls, I was hoping for a more up to date jquery for the sake of compatibility.

Is there a way I can write a javascript call to remove the:

<script type="text/javascript" src="/misc/jquery.js?K"></script> 

and then call my own?

share|improve this question

migrated from stackoverflow.com Jan 28 '13 at 14:26

This question came from our site for professional and enthusiast programmers.

add comment

4 Answers

up vote 0 down vote accepted

It's a lot simpler than you thought my friend, You can simply add your new jQuery version, add it after the older version, the older version and it's plugins will be overridden.

<script type="text/javascript" src="/misc/jquery.js?K"></script> 
...
...
<script type="text/javascript" src="/misc/jquery-BRAND-NEW-jQuery.js"></script> 
share|improve this answer
5  
-1: This must be the worst possible way to approach the problem. –  tereško Jan 26 '13 at 21:14
1  
@tereško, waiting to see yours. :( –  gdoron Jan 26 '13 at 21:14
2  
removing the older version means asking. then begging. Then waiting while a very slow moving organization decides if a change would affect anything negatively and what impact the change would have on all the other existing sites. Then getting put on the queue while they get to it. I've tried doing this with them before on something a lot more minor. It took two months for them to say "Sorry, we can't do it" –  Lars Townsend Jan 26 '13 at 21:21
1  
@LarsTownsend, ok now I understand - as I say, I am not familiar with Drupal. Ok so do as above - reference the new version of jQuery as close as possible, but after, the old version of jQuery. +1 as the answer is correct. –  ClarkeyBoy Jan 26 '13 at 21:24
1  
Apparently there is actually a jQuery update module in Drupal - check here. Not sure if this would be an option..? –  ClarkeyBoy Jan 26 '13 at 21:27
show 10 more comments

You cannot just push a newer version jQuery by adding/replacing the tag. Drupal and some modules bundles their own JavaScript that rely on that specific version of jQuery, updating jQuery may break these JavaScript. Most of these script require the jQuery object (from jQuery 1.2.6) to be binded to $.

If really needed, you can load an newer version of jQuery in noConflict mode, treating the old jQuery as a an other library. So $ will still be the old jQuery object for the existing script. Andyou can use newer jQuery version using jQuery in your script. Properly written plugins and libraries should access the jQuery object using jQuery instead of $ and so should be loadable (after calling the noConflict() method). IF not, you may need to fix them.

share|improve this answer
add comment

You might want to take a look at the JQuery Update module. That will take Drupal 6 to JQuery 1.3.2. It also will show you which Drupal core JS files need modified to work with newer versions of JQuery.

share|improve this answer
add comment

Actually, upon further research, I found an answer here:

http://drupal.org/node/1058168

I used the last solution, unset the old jquery from the $script array and put in 1.8.3 which seems to work so far.

share|improve this answer
add comment

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.