configuring jquery_update to use jquery via Google CDN?

PGNetDev - July 20, 2009 - 20:11
Project:jQuery Update
Version:6.x-2.x-dev
Component:Miscellaneous
Category:support request
Priority:normal
Assigned:Unassigned
Status:needs review
Description

hi,

i've installed jquery_update w/ drupal v6.13,

version = "6.x-2.x-dev"
core = "6.x"
project = "jquery_update"
datestamp = "1240532053"

iiuc, the module packages a local instance of jquery.

(1) google's now making ajax libs avaiable via its cdn (http://code.google.com/apis/ajaxlibs/documentation/index.html#jquery)

can jquery_update be _configured_ to use a remote instance of the libs? if so, i've missed the config ...

(2) the README.txt says,

"3. Visit Administer > Site Configuration > jQuery Update to configure the module."

i've verified that the module *is* activated, but there's no such menu option @ "Site Configuration". any hints?

thanks!

#1

mfer - July 21, 2009 - 11:52

2 things....

First, be aware that not everyone has access to the js in the google cdn. There are some countries (like Iran) that block it.

Second, Drupal 6 core doesn't support external JavaScripts. It may be possible to support this with a hack of sorts.

This can go on the mid term todo list. But, before you pursue this re-read the first point and consider what your site will be like when js breaks for people in those countries.

#2

PGNetDev - July 21, 2009 - 14:42

hi,

> be aware that not everyone has access to the js in the google cdn.

understood.

> Second, Drupal 6 core doesn't support external JavaScripts. It may be possible to support this with a hack of sorts.

i did not realize that ... i note that . e,g, yui-editor module allows use of external js ... does it not touch core as well?

> This can go on the mid term todo list.

thanks!

#3

kiamlaluno - August 6, 2009 - 20:56

drupal_add_js(), which is the function a module should use to add a reference to a JavaScript file into the page, doesn't allow to use a reference to a file that is not on the local server that is running Drupal.

#4

renee - August 17, 2009 - 14:26

I too need this - the biggest reason is that the jQuery folks themselves request this, so that it will be more likely to be cached from other sites and thus speed up the user's browsing experience, rather than re-downloading multiple jquery.js files from various websites that all have the same source. It's becoming one of the most heavily used libraries out there, especially given its inclusion in many CMSes, so this seems like a great idea...

Any ideas?

#5

jamestamr - November 10, 2009 - 13:26

This would be a great addition.

#6

renee - November 10, 2009 - 21:19

One thought - due to Drupal's aggregation if cache is enabled, this would need to be outside of that to do any good (ie: to allow it to be cached on the client across sites)

#7

recrit - November 27, 2009 - 03:22
Status:active» needs review

The attached patch to 6.x-2.x-dev accomplishes the following:

  • provides an additional option to use "Google CDN (External, Minified, Compressed)"
  • updates to supporting functions to handle the new options
  • adds a script tag for http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js - does not add this using drupal_add_js
    • added before any other scripts
    • it is not included in aggregation

Is it a little hacky? Yes.. but it works as expected and takes the load off of your server using a free CDN.
Comment if anyone has a better way of accomplishing this.

AttachmentSize
jquery_update_GoogleCDN_525436.patch 3.21 KB
 
 

Drupal is a registered trademark of Dries Buytaert.