Jeremy French
Jeremy French

Reputation: 12177

Proper way to include a jQuery library

I am working on a module for Drupal 7. I am using some of the jQuery UI modules which are included.

my natural way to include these is to use drupal_add_js() and drupal_add_css() with the relevant files. However this feels a little wrong. Is there an official (or better) way to include these libraries, either from Drupal or jQuery.

I tend to find the Drupal/jQuery interface very powerful but frustratingly sparse on documentation.

Upvotes: 2

Views: 1721

Answers (2)

Amitesh Ranjan
Amitesh Ranjan

Reputation: 1532

Even though your question was in the context of drupal, I found this which I though of putting as my answer:

http://encosia.com/3-reasons-why-you-should-let-google-host-jquery-for-you/

It has a nice explanation on why google hosting is recommended. And it serves all the purposes. Might be helpful for others who come to this page. :)

Upvotes: 0

Jeremy French
Jeremy French

Reputation: 12177

Found it! drupal_add_library() does precicely what I wanted, also looks like there are a few other library hooks.

Sorry for answering my own question.

Upvotes: 6

Related Questions