2

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

The Advanced CSS/JS Aggregation module seems promising, but after installing it and trying to use the Google CDN in the standard way, for example using drupal_set_html_head() to add the following lines in <head>, those files aren't available.

<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>

How can I get the latest jQuery and jQuery UI from a CDN like Google CDN?

6
  • 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'); Commented Jul 25, 2011 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.
    – minou
    Commented Jul 25, 2011 at 14:16
  • @jeff the advagg module does enable that. Commented Jul 25, 2011 at 14:39
  • @Jeff Oh ya. You are right. I just cleared it. Thanks. Commented Jul 25, 2011 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?
    – minou
    Commented Jul 25, 2011 at 15:12

2 Answers 2

2

Drupal 6 ships with jQuery 1.2.3 and the jQuery Update module can push it 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 its workings, so it isn't straightforward to put a new version on top.

Otherwise, those files are available in https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.14/jquery-ui.min.js.

2
  • 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.
    – minou
    Commented Jul 25, 2011 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.
    – minou
    Commented Jul 25, 2011 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

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.