2

For my Drupal 6 site, I'd like to get the latest jQuery and jQuery-ui scripts from the Google CDN. Although this seems like something that many people would want to do, it seems that it is not so easy.

The project Advanced CSS/JS Aggregation (advagg) seems promising, but after installing it and trying to use the Google CDN in the standard way, e.g., adding

<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.14/jquery-ui.min.js"></script>

to the head of a Drupal page, those files are not available.

Any ideas for how to do this?

EDIT:

I used drupal_set_html_head() to add the above lines to the HEAD of the Drupal page where I want to use jQuery and jQueryUI. I verified that this was working by viewing the page source.

  • How are you loading this? Are you manually editing page.tpl.php for this? If there are a number of page-*.tpl.php then are you correctly adding on all files. The correct way is to use drupal_add_js('path/to/js'); – Shoaib Nawaz Jul 25 '11 at 5:26
  • @Shoaib, my understanding is that drupal_add_js in Drupal 6 is only for local javascript and does not work with external javascript, such as from a CDN. Please correct me if I'm wrong. – gaefan Jul 25 '11 at 14:16
  • @jeff the advagg module does enable that. – Jeremy French Jul 25 '11 at 14:39
  • @Jeff Oh ya. You are right. I just cleared it. Thanks. – Shoaib Nawaz Jul 25 '11 at 14:52
  • @Jeremy, any thoughts as to why what I did above didn't work? Or can you point me to some docs for advagg that might explain more? – gaefan Jul 25 '11 at 15:12
2

Those files look to be available https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.14/jquery-ui.min.js

update

As to why it didn't work:

  • Jquery that ships with drupal 6 is 1.2.3
  • The Jquery update module can push this to 1.3.2

You are trying to use a much more recent version of jquery than Drupal 6 can handle. Drupal uses a lot of jQuery in it's workings, so it is not straightforward to put a new version on top. Sorry I didn't spot that earlier.

| improve this answer | |
  • They are, but I can't get them to work in Drupal. I'm able to use them on non-Drupal sites,e.g., Google app engine sites. – gaefan Jul 25 '11 at 14:13
  • Thanks, I'll try the above with jQuery 1.3.2 and jQueryUI 1.7.3 (which other people have got working without CDN) and report back how it goes. – gaefan Jul 25 '11 at 16:02
0

You can use the lastest version of JQuery and JQuery UI in Drupal 6 by using jQuery.noConflict(). This will allow you to have both multiple versions of the library for specific needs.

See the Drupal documentation here:

Using Newer Versions of jQuery with Drupal 6

| improve this answer | |

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.